Part Number Hot Search : 
T24C0 29F16 KMB7D0NP C1602 A1088 MS3106A 74VHC10 KK74HC
Product Description
Full Text Search
 

To Download SN8F27E64 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 1 version 1. 4 sn8 f 27 e60 series users manual version 1. 4 sn8f27e65 SN8F27E64 sn8f27e62 sn8f27e65l SN8F27E64l sn8f27e62l s s o o n n i i x x 8 8 - - b b i i t t m m i i c c r r o o - - c c o o n n t t r r o o l l l l e e r r sonix reserves the right to make change without further notice to any products herein to impr ove reliability, function or design . sonix does not assume any liability arising out of the application or use of any product or circuit described herein; neither does it convey any license under its patent rights nor the rights of others. sonix products a re not designed, intended, or authorized for us as components in systems intended, for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the f ailure of the sonix product could c reate a situation where personal injury or death may occur. should buyer purchase or use sonix products for any such unintend ed or unauthorized application. buyer shall indemnify and hold sonix and its officers, employees, subsidiaries, affiliates and dist ributors harmless against all claims, cost, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use even if such claim alleges tha t sonix was negligent regarding the design or manufacture of the part.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 2 version 1. 4 amendent history version date description ver 0.1 oct . 200 9 first issue. ver 0. 2 dec . 200 9 1. update electrical characteristic. 2. modify development tool section. ver 0. 3 dec . 200 9 1. up date electrical characteristic. 2. modify uart section. ver 0. 4 jan . 20 10 1. update electrical characteristic. 2. add p b - f ree part number. 3. add qfn package type. ver 0. 5 feb . 20 10 1. fix sn8f27e65lf pin 31/32 vdd name. 2. modify wafer form part number as s8f27e65w . ver 1.0 jul . 20 10 1. update electrical characteristic. 2. modify msp section. 3. modify qfn 4x4 package dimension. ver 1. 1 jun . 201 1 1. update rom programming pin. 2. modify qfn 4x4 package dimension. 3. add avrefh pin name in SN8F27E64 and sn8f27e62. 4. modify sn8f27e65 starter - kit section. 5. update electrical characteristic maximum rating . ver 1.2 jul. 2011 1. add sdip package type . ver 1. 3 ju n . 201 2 1. add the schematic of sn8f27e65 starter - kit . ver 1. 4 may 201 3 1. modify adc section.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 3 version 1. 4 table of content amendent history ................................ ................................ ................................ ................................ 2 1 1 1 product overview ................................ ................................ ................................ .............................. 8 1.1 features ................................ ................................ ................................ ................................ .............. 8 1.2 system block diagram ................................ ................................ ................................ .............. 10 1.3 pin assignment ................................ ................................ ................................ ............................... 11 1.4 pin descriptions ................................ ................................ ................................ ............................. 13 1.5 pin circuit diagrams ................................ ................................ ................................ ................... 14 2 2 2 central processor un it (cpu) ................................ ................................ ................................ ... 16 2.1 program memory (flash rom) ................................ ................................ ................................ 16 2.1.1 reset vector (0000h) ................................ ................................ ................................ ............. 17 2.1.2 interrupt vector (0008h~0014h) ................................ ................................ ....................... 18 2.1.3 look - up table description ................................ ................................ ............................... 20 2.1.4 jump table description ................................ ................................ ................................ ...... 22 2.1.5 checksum calculation ................................ ................................ ................................ ...... 24 2.2 data memory (ram) ................................ ................................ ................................ ...................... 25 2.2.1 system register ................................ ................................ ................................ ..................... 26 2.2.1.1 system register table ................................ ................................ ................................ 26 2.2.1.2 system register description ................................ ................................ ................... 26 2.2.1.3 bit definition of system register ................................ ................................ ........... 27 2.2.2 accumulator ................................ ................................ ................................ .......................... 29 2.2.3 program flag ................................ ................................ ................................ .......................... 30 2.2.4 program counter ................................ ................................ ................................ .................. 31 2.2.5 h, l registers ................................ ................................ ................................ ............................ 34 2.2.6 x registers ................................ ................................ ................................ ................................ 35 2.2.7 y, z registers ................................ ................................ ................................ ............................ 35 2.2.8 r register ................................ ................................ ................................ ................................ .. 36 2.2.9 w registers ................................ ................................ ................................ ............................... 37 2.3 addressing mode ................................ ................................ ................................ ........................... 38 2.3.1 immediate addressing mode ................................ ................................ ........................... 38 2.3.2 directly addressing mode ................................ ................................ .............................. 38 2.3.3 indirectly addressing mode ................................ ................................ .......................... 38 2.4 stack operation ................................ ................................ ................................ ............................ 39 2.4.1 overview ................................ ................................ ................................ ................................ .... 39 2.4.2 stack pointer ................................ ................................ ................................ .......................... 39 2.4.3 stack buffer ................................ ................................ ................................ ............................ 40 2.4.4 stack overflow indicator ................................ ................................ .............................. 40 2.4. 5 stack operation example ................................ ................................ ................................ . 41 2.5 code option table ................................ ................................ ................................ ........................ 42 2.5.1 fcpu code option ................................ ................................ ................................ ............................ 43 2.5.2 reset_pin code option ................................ ................................ ................................ ..................... 43 2.5.3 security code option ................................ ................................ ................................ ........................ 43 2.5.4 noise filter code option ................................ ................................ ................................ .................. 43 3 3 3 reset ................................ ................................ ................................ ................................ .......................... 44 3.1 overview ................................ ................................ ................................ ................................ ........... 44 3.2 power on reset ................................ ................................ ................................ ............................... 45 3.3 watchdog reset ................................ ................................ ................................ ............................ 45 3.4 brown out reset ................................ ................................ ................................ ........................... 45 3.4.1 the system operating voltage ................................ ................................ ..................... 46
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 4 version 1. 4 3.4.2 low voltage detector (lvd) ................................ ................................ .......................... 46 3.4.3 brown out reset improvement ................................ ................................ ...................... 48 3.5 external reset ................................ ................................ ................................ .............................. 49 3.6 external reset circuit ................................ ................................ ................................ ............. 49 3.6.1 simply rc reset circuit ................................ ................................ ................................ ................. 49 3.6.2 diode & rc reset circuit ................................ ................................ ................................ ............... 50 3.6.3 zener diode reset circuit ................................ ................................ ................................ ............... 50 3.6.4 voltage bias reset circuit ................................ ................................ ................................ .............. 51 3.6.5 external reset ic ................................ ................................ ................................ ............................. 5 1 4 4 4 system clock ................................ ................................ ................................ ................................ ....... 52 4.1 overview ................................ ................................ ................................ ................................ ........... 52 4.2 f cpu (instruction cycle) ................................ ................................ ................................ ............ 52 4.3 noise filter ................................ ................................ ................................ ................................ ...... 52 4.4 system high - speed clock ................................ ................................ ................................ .......... 52 4.4.1 high_clk code option ................................ ................................ ................................ .......... 53 4.4.2 internal high - speed oscillator rc type (ihrc) ................................ .................... 53 4.4.3 external high - speed oscillator ................................ ................................ .................. 53 4.4.4 external oscillator application circuit ................................ .............................. 53 4.5 syst em low - speed clock ................................ ................................ ................................ ........... 54 4.6 oscm register ................................ ................................ ................................ ................................ . 54 4.7 system clock measurement ................................ ................................ ................................ ... 55 4.8 system clock timing ................................ ................................ ................................ ................... 55 5 5 5 system operation mod e ................................ ................................ ................................ ................ 58 5.1 overview ................................ ................................ ................................ ................................ ........... 58 5.2 normal mode ................................ ................................ ................................ ................................ ... 59 5.3 slow mode ................................ ................................ ................................ ................................ ......... 60 5.4 power down mdoe ................................ ................................ ................................ ......................... 60 5.5 green mode ................................ ................................ ................................ ................................ ....... 61 5.6 operating mode control macro ................................ ................................ .......................... 62 5.7 wakeup ................................ ................................ ................................ ................................ ............... 63 5.7.1 overview ................................ ................................ ................................ ................................ .... 63 5.7.2 wakeup time ................................ ................................ ................................ ............................. 63 5.7.3 p1w wakeup control register ................................ ................................ ....................... 64 6 6 6 interrupt ................................ ................................ ................................ ................................ ................ 65 6.1 overview ................................ ................................ ................................ ................................ ........... 65 6.2 i nterrupt o peration ................................ ................................ ................................ ........................... 65 6.3 inten interrupt enable register ................................ ................................ ......................... 66 6.4 intrq interrupt request register ................................ ................................ ....................... 67 6.5 gie global interrupt op eration ................................ ................................ .......................... 68 6.6 external interrupt operation (int0~int1) ................................ ................................ ...... 69 6.7 t0 interrupt operation ................................ ................................ ................................ .............. 70 6.8 tc0 interrupt operation ................................ ................................ ................................ ........... 71 6.9 tc1 interrupt operation ................................ ................................ ................................ ........... 72 6.10 tc2 interrupt operation ................................ ................................ ................................ ......... 73 6.11 t1 interrupt operation ................................ ................................ ................................ ............ 74 6.12 adc interrupt operation ................................ ................................ ................................ ........ 75 6.13 sio i nterrupt operation ................................ ................................ ................................ .......... 76 6.14 uart interrupt operation ................................ ................................ ................................ ..... 77 6.15 multi - interrupt operation ................................ ................................ ................................ ... 78 7 7 7 i/o port ................................ ................................ ................................ ................................ ..................... 79 7.1 overview ................................ ................................ ................................ ................................ ........... 79 7.2 i/o port mode ................................ ................................ ................................ ................................ ... 80
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 5 version 1. 4 7.3 i/o pull up register ................................ ................................ ................................ ...................... 81 7.4 i/o port data register ................................ ................................ ................................ ................ 82 7.5 port 4, port 5 adc share pin ................................ ................................ ................................ ........ 83 7.6 open - drain register ................................ ................................ ................................ .................... 85 8 8 8 timers ................................ ................................ ................................ ................................ ....................... 86 8.1 watchdog timer ................................ ................................ ................................ ............................ 86 8.2 t0 8 - bit basic timer ................................ ................................ ................................ .............................. 88 8.2.1 overview ................................ ................................ ................................ ................................ .... 88 8.2.2 t0 timer operation ................................ ................................ ................................ ......................... 89 8.2.3 t0m mode register ................................ ................................ ................................ ................ 90 8.2.4 t0c counting register ................................ ................................ ................................ ........ 90 8.2.5 t0 timer operat ion explame ................................ ................................ ............................ 91 8.3 tc0 8 - bit timer/counter ................................ ................................ ................................ ............. 92 8.3.1 overview ................................ ................................ ................................ ................................ .... 92 8.3.2 tc0 timer operation ................................ ................................ ................................ ............. 93 8.3.3 tc0m mode register ................................ ................................ ................................ .............. 94 8.3.4 tc0c counting register ................................ ................................ ................................ ..... 94 8.3.5 tc0r auto - reload register ................................ ................................ .............................. 95 8.3.6 tc0d pwm duty register ................................ ................................ ................................ .... 95 8.3.7 tc0 event counter ................................ ................................ ................................ ................ 96 8.3.8 pulse width modulation (pwm) ................................ ................................ ..................... 96 8.3.9 tc0 timer operation explame ................................ ................................ ......................... 97 8.4 tc1 8 - bit timer/counter ................................ ................................ ................................ ............. 99 8.4.1 overview ................................ ................................ ................................ ................................ .... 99 8.4.2 tc1 timer operation ................................ ................................ ................................ ........... 100 8.4.3 tc1m mode register ................................ ................................ ................................ ............ 101 8.4.4 tc1c counting register ................................ ................................ ................................ ... 101 8.4.5 tc1r auto - reload register ................................ ................................ ............................ 102 8.4.6 tc1d pwm duty register ................................ ................................ ................................ .. 102 8.4.7 tc1 event counter ................................ ................................ ................................ .............. 103 8.4.8 pulse widt h modulation (pwm) ................................ ................................ ................... 103 8.4.9 tc1 timer operation explame ................................ ................................ ....................... 104 8.5 tc2 8 - bit timer/counter ................................ ................................ ................................ ........... 106 8.5.1 overview ................................ ................................ ................................ ................................ .. 106 8.5.2 tc2 timer operation ................................ ................................ ................................ ........... 107 8.5.3 tc2m mode register ................................ ................................ ................................ ............ 108 8.5.4 tc2c counting register ................................ ................................ ................................ ... 108 8.5.5 tc2r auto - reload register ................................ ................................ ............................ 109 8.5.6 tc2d pwm d uty register ................................ ................................ ................................ .. 109 8.5.7 tc2 event counter ................................ ................................ ................................ .............. 110 8.5.8 pulse width modulation (pwm) ................................ ................................ ................... 110 8.5.9 tc2 timer operation explame ................................ ................................ ....................... 111 8.6 t1 16 - bit t imer with c apture t imer f unction ................................ ................................ .............. 113 8.6.1 overview ................................ ................................ ................................ ................................ .. 113 8.6.2 t1 timer operation ................................ ................................ ................................ .............. 113 8.6.3 t1m mode register ................................ ................................ ................................ .............. 114 8.6.4 t1ch, t1cl 16 - bit counting registers ................................ ................................ ........... 115 8.6.5 t1 cpature timer ................................ ................................ ................................ .................. 116 8.6.5.1 capture timer ................................ ................................ ................................ ......................... 116 8.6.5.2 high pulse width measurement ................................ ................................ ............................. 117 8.6.5.3 low pulse width measurement ................................ ................................ ............................. 117 8.6.5.4 input cyc le measurement ................................ ................................ ................................ ....... 118
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 6 version 1. 4 8.6.6 capture timer control registers ................................ ................................ ............. 118 8.6.7 t1 timer operation explame ................................ ................................ .......................... 119 9 9 9 12 channel analog to digital converter (a dc) ................................ .......................... 122 9.1 overview ................................ ................................ ................................ ................................ ......... 122 9.2 adc mode register ................................ ................................ ................................ ..................... 123 9.3 adc data buffer registers ................................ ................................ ................................ .... 124 9.4 adc operation description and notic ................................ ................................ ............. 125 9.4.1 adc signal format ................................ ................................ ................................ ............. 125 9.4.2 adc converting time ................................ ................................ ................................ ......... 125 9.4.3 adc pin configuration ................................ ................................ ................................ ..... 126 9.4.4 adc operation examlpe ................................ ................................ ................................ ... 127 9.5 adc application circuit ................................ ................................ ................................ ................ 129 1 1 1 0 0 0 universal asynchrono u s receiver/transmitt er (uart) ................................ ..... 1 30 10.1 overview ................................ ................................ ................................ ................................ ....... 130 10.2 uart operation ................................ ................................ ................................ .......................... 131 10.3 uart baud rate ................................ ................................ ................................ .......................... 132 10.4 uart transfer format ................................ ................................ ................................ ................... 133 10.5 break pocket ................................ ................................ ................................ ............................... 133 10.6 abnormal pocket ................................ ................................ ................................ ..................... 134 10.7 uart receiver control register ................................ ................................ ...................... 134 10.8 uart transmitter control register ................................ ................................ ............. 135 10.9 uart data buffer ................................ ................................ ................................ ...................... 135 10.10 uart operation examlpe ................................ ................................ ................................ .... 136 1 1 1 1 1 1 serial input/output transceiver (sio) ................................ ................................ ............ 139 11.1 overview ................................ ................................ ................................ ................................ ....... 139 11.2 sio operation ................................ ................................ ................................ ............................... 139 11.3 siom mode register ................................ ................................ ................................ .................. 142 11.4 siob data buffer ................................ ................................ ................................ ....................... 143 11.5 sior register description ................................ ................................ ................................ ..... 144 1 1 1 2 2 2 main serial port (ms p) ................................ ................................ ................................ ................ 145 12.1 overview ................................ ................................ ................................ ................................ ....... 145 12.2 msp status register ................................ ................................ ................................ ................. 145 12.3 msp mode register 1 ................................ ................................ ................................ ................. 146 12.4 msp mode register 2 ................................ ................................ ................................ ................. 147 12.5 msp ms pbuf register ................................ ................................ ................................ ................ 148 12.6 msp mspadr register ................................ ................................ ................................ ............... 148 12.7 s lave m ode o peration ................................ ................................ ................................ .................... 148 12.7.1 addressing ................................ ................................ ................................ ................................ ... 148 12.7.2 slave receiving ................................ ................................ ................................ ........................... 149 12.7.3 slave transmission ................................ ................................ ................................ ...................... 149 12.7.4 general call address ................................ ................................ ................................ ................... 150 12.7.5 slave wake up ................................ ................................ ................................ ............................. 151 12.8 m aster mode ................................ ................................ ................................ ................................ ..... 153 12.8.1 mater mode support ................................ ................................ ................................ .................... 153 12.8.2 msp rate generator ................................ ................................ ................................ .................... 153 12.8.3 msp mater start con dition ................................ ................................ ................................ .... 154 12.8.3.1 wcol status flag ................................ ................................ ................................ ................ 154 12.8.4 msp master mode repeat start condition ................................ ................................ ............ 154 12.8.4.1 wcol status flag ................................ ................................ ................................ ................ 154 12.8.5 acknowledge sequence timing ................................ ................................ ................................ .. 155 12.8.5.1 wcol status flag ................................ ................................ ................................ ................ 155 12.8.6 stop condition timing ................................ ................................ ................................ .............. 155
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 7 version 1. 4 12.8.6.1 wcol status flag ................................ ................................ ................................ ................ 155 12. 8.7 clock arbitration ................................ ................................ ................................ ......................... 156 12.8.8 master mode transmission ................................ ................................ ................................ ......... 156 12.8.8.1 bf status flag ................................ ................................ ................................ ...................... 156 12.8.8.2 wcol flag ................................ ................................ ................................ .......................... 156 12.8.8.3 ackstat status flag ................................ ................................ ................................ ......... 156 12.8.9 master mode receiving ................................ ................................ ................................ ............... 157 12.8.9.1 bf status flag ................................ ................................ ................................ ...................... 157 12.8.9.2 mspov flag ................................ ................................ ................................ ........................ 157 12.8.9.3 wcol flag ................................ ................................ ................................ .......................... 157 1 1 1 3 3 3 in system program fl ash rom ................................ ................................ .............................. 158 13.1 overview ................................ ................................ ................................ ................................ ....... 158 13.2 isp flas h rom erase operation ................................ ................................ .......................... 159 13.3 isp flash rom program operation ................................ ................................ ................... 160 13.4 isp program/erase control register ................................ ................................ ............. 163 13.5 isp rom address register ................................ ................................ ................................ ...... 163 13.6 isp ram address register ................................ ................................ ................................ ...... 163 13.7 isp rom programming length register ................................ ................................ ......... 164 1 1 1 4 4 4 instruction table ................................ ................................ ................................ ........................ 165 1 1 1 5 5 5 electrical character istic ................................ ................................ ................................ ... 167 15.1 absolute maximum rating ................................ ................................ ................................ .. 167 15.2 electrical characteristic ................................ ................................ ................................ . 167 15.3 characteristic graphs ................................ ................................ ................................ .......... 169 1 1 1 6 6 6 development tool ................................ ................................ ................................ ....................... 170 16.1 s mart d evelopment a dapter ................................ ................................ ................................ ........ 171 16.2 sn8 f27e65 s tarter - kit ................................ ................................ ................................ ................... 172 16.3 e mulator / debugger i n stallation ................................ ................................ ........................... 173 16.4 programmer i n stallation ................................ ................................ ................................ ......... 174 1 1 1 7 7 7 rom programming pin ................................ ................................ ................................ ................ 175 17.1 mp - iii writer transition board socket pin assignment ................................ ....... 175 17.2 mp - iii writer programming pin mapping: ................................ ................................ ....... 176 1 1 1 8 8 8 marking definition ................................ ................................ ................................ ...................... 179 18.1 introduction ................................ ................................ ................................ .............................. 179 18.2 marking indetification system ................................ ................................ ........................ 179 18.3 marking example ................................ ................................ ................................ ...................... 180 18.4 datecode system ................................ ................................ ................................ ...................... 181 1 1 1 9 9 9 package information ................................ ................................ ................................ ................ 182 19.1 p - dip 32 pin ................................ ................................ ................................ ................................ ...... 182 19.2 lqfp 32 pin ................................ ................................ ................................ ................................ ....... 183 19.3 qfn 5 x 5 32 pin ................................ ................................ ................................ ................................ . 184 19.4 s - dip 32 pin ................................ ................................ ................................ ................................ ...... 185 19.5 sk - dip 28 pin ................................ ................................ ................................ ................................ ... 186 19.6 sop 28 pin ................................ ................................ ................................ ................................ ......... 187 19.7 ssop 28 pin ................................ ................................ ................................ ................................ ....... 188 19.8 qfn 4 x 4 28 pin ................................ ................................ ................................ ................................ . 189 19.9 p - dip 20 pin ................................ ................................ ................................ ................................ ...... 19 0 19.10 sop 20 pin ................................ ................................ ................................ ................................ ....... 191
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 8 version 1. 4 1 1 1 product overview sn8f27e60 series 8 - bit micro - contro ller is a new series production applied advanced semiconductor technology to implement flash rom architecture. under flash rom platform, sn8f27e60 builds in in - system - programming (isp) function extending to eeprom emulation and embedded ice function. it o f fer s high performance 12 - ch 10 - bit adc, 3 - set individual programmable pwms, 3 - type serial interfaces and flexible operating modes. powerful functionality, high reliability and low power consumption can apply to ac power application and battery level applic ation easily. 1.1 features ? memory configuration ? four 8 - bit timer. (t0, tc0, tc1, tc2). flash rom size: 6k x 16 bits. including eerom t0: basic timer. emulation. (in system programming) tc0: timer/counter/pwm0. ram size: 512 x 8 bits. tc1: tim er/counter/pwm1. ? 8 levels stack buffer. tc2: timer/counter/pwm2 ? 13 interrupt sources ? 3 channel duty/cycle programmable pwm to 11 internal interrupts: t0, tc0, tc1, tc2, t1, adc, generate pwm, buzzer and ir carrier signals. sio, msp, utx(u a rt tx), urx(u a r t rx), wake (pwm0~2) . 2 external interrupts: int0, int1 ? one 16 - bit timer (t1) with capture timer function. ? multi - interrupt vector structure. ? each of interrupt sources has a unique interrupt vector. ? ? ? i/o pin configuration ? four system clocks bi - directional: p0, p1, p4, p5. external high clock: rc type up to 10mhz wakeup: p0, p1 level change. external high clock: crystal typ e up to 16mhz pull - up resisters: p0, p1, p4, p5. internal high clock: rc type 16mhz external interrupt: p0.0, p0.1 internal low clock: rc type 16khz adc input pin: ain0~ain11. ? four operating modes normal mode: both high and low clock active ? fcpu (instruction cycle) slow mode: low clock only fcpu = fhosc/1, fhosc/2, fhosc/4, fhosc/8, fhosc/16, sleep mode: both high and low clock stop fhosc/32, fhosc/64, fhosc/128 green mode: periodical wakeup by timer ? on chip watchdog timer and cl ock source ? ? 1.8v/2.4v/3. 3 v 3 - level lvd with trim. pdip 32 pin lqfp 32 pin ? powerful instructions qfn 32 pin instructions length is one word. sdip 32 pin most of instructions are one cycle only. skdip 28 pin all rom area jmp instruction. sop 28 pin all rom area lookup table function (movc). s sop 28 pin qfn 28 pin dip 2 0 pin sop 2 0 pin
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 9 version 1. 4 sn8 f 27e60 series micro - controller includes two types for different power types. for ac power type (al tern ating current power source) and dc high voltage power ( Q 5.5v), the power pin has vdd and vddl. vdd pin is connect to dc power source from dc - dc inverter or regulator and connects a 0.1uf capacitor to vss pin (ground). vddl is internal power terminal, not connect with power source, and only connects a 0.1uf cap acitor to vss pin (ground). this pin assignment has high power noise immunity, but the static current is larger. the application field is household, motor control for dc power type (battery power source), the power pin is vd d. vdd pin is connect to dc power source from battery and connects a 0.1uf capacitor to vss pin (ground). this pin assignment has low power noise immunity, but the static current is very low. the application field is portable application ? features selection table sn8f27e60 series chip rom ram stack timer i/o pwm adc sio uart msp ext.int isp/ embedded ice operating voltage package sn8f27e65 6k *16 512 8 8 - bit*4 16 - bit*1 27 3 - ch 12 - ch v v v 2 v 1.8v~5.5v dip32 lqfp32 qfn32 sdip 32 sn8f27e6 4 6k *16 512 8 8 - bit*4 16 - bit*1 25 3 - ch 11 - ch v v v 2 v 1.8v~5.5v skdip28 sop28 ssop28 qfn28 sn8f 27e62 6k *16 512 8 8 - bit*4 16 - bit*1 17 3 - ch 9 - ch - v - 1 v 1.8v~5.5v dip20 sop20 sn8f27e60l series chip rom ram stack timer i/o pwm adc sio uart m sp ext.int isp/ embedded ice operating voltage package sn8f27e65 l 6k *16 512 8 8 - bit*4 16 - bit*1 27 3 - ch 12 - ch v v v 2 v 1.8v~3.3v dip32 lqfp32 qfn32 sdip32 sn8f27e6 4l 6k *16 512 8 8 - bit*4 16 - bit*1 25 3 - ch 11 - ch v v v 2 v 1.8v~3.3v skdip28 sop28 ssop28 qfn2 8 sn8f 27e62l 6k *16 512 8 8 - bit*4 16 - bit*1 17 3 - ch 9 - ch - v - 1 v 1.8v~3.3v dip20 sop20 s n 8 f 2 7 e 6 0 s e r i e s m c u v d d v d d l v s s r e g u l a t o r 0 . 1 u f 0 . 1 u f r e c t i f i c a t i o n a c p o w e r s o u r c e + - l n s n 8 f 2 7 e 6 0 s e r i e s m c u v d d v d d l v s s 0 . 1 u f 0 . 1 u f d c p o w e r s o u r c e ( 1 . 8 v ~ 5 . 5 v ) + - ( 1 . 8 v ~ 5 . 5 v ) s n 8 f 2 7 e 6 0 l s e r i e s m c u v d d v s s r e g u l a t o r 0 . 1 u f d c p o w e r s o u r c e ( > 3 . 3 v ) + - s n 8 f 2 7 e 6 0 l s e r i e s m c u v d d v s s 0 . 1 u f d c p o w e r s o u r c e ( 1 . 8 v ~ 3 . 3 v ) + - ( 1 . 8 v ~ 3 . 3 v )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 10 version 1. 4 1.2 system block diagram i n t e r r u p t c o n t r o l e x t e r n a l h i g h o s c . a c c i n t e r n a l l o w r c t i m i n g g e n e r a t o r r a m s y s t e m r e g i s t e r s 3 - l e v e l l v d ( l o w v o l t a g e d e t e c t o r ) w a t c h d o g t i m e r t i m e r & c o u n t e r p 0 p 5 p 1 u a r t s i o a l u p c f l a g s i r f l a s h r o m s c k , s d i , s d o , s c s p 4 i n t e r n a l h i g h r c 1 6 m h z m s p s c l , s d a a i n 0 ~ a i n 1 1 u t x , u r x p w m 2 p w m 2 1 2 - c h 1 0 - b i t a d c p w m 1 p w m 0 p w m 1 p w m 0 e m b e d d e d i c e s y s t e m e i d a , e i c k
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 11 version 1. 4 1.3 pin assignment ? sn8f27e65p (ac field , dip 32 pin ) : ? sn8f27e65 u (ac field, s dip 32 pin): ? sn8f27e65lp (dc field , di p 32 pin ) : ? sn8f27e65l u (dc field, s dip 32 pin): vss 1 u 32 vddl xin/p0.6 2 31 vddl xout/p0.5 3 30 vdd rst/p0.4 4 29 avrefh p0.3/utx/t1 5 28 p4.0/ain0 p0.2/urx/tc2 6 27 p4.1/ain1 p0.1/int1/tc1 7 26 p4.2/ain2 p0.0/int0/tc0 8 25 p4.3/ain3 p1.7 /scs 9 24 p4.4/ain4 p1.6/sck 10 23 p4.5/ain5 p1.5/sdi 11 22 p4.6/ain6 p1.4/sdo 12 21 p4.7/ain7 p1.3/scl 13 20 p5.0/ain8 p1.2/sda 14 19 p5.1/ain9/pwm0 p1.1/eida 15 18 p5.2/ain10/pwm1 p1.0/eick 16 17 p5.3/ain11/pwm2 vss 1 u 32 vdd xin/p0.6 2 31 vdd xout/p0.5 3 30 vdd rst/p0.4 4 29 avrefh p0.3/utx/t1 5 28 p4.0/ain0 p0.2/urx/tc2 6 27 p4.1/ain1 p0.1/int1/tc1 7 26 p4.2/ain2 p0.0/int0/tc0 8 25 p4.3/ain3 p1.7/scs 9 24 p4.4/ain4 p1.6/sck 10 23 p4.5/ain5 p1.5/sdi 11 22 p4.6/ain6 p1.4/sdo 12 21 p4.7/ain7 p1.3/scl 13 20 p5.0/ain8 p1.2/sda 14 19 p5.1/ain9/pwm0 p1.1/eida 15 18 p5.2/ain10/pwm1 p1.0/eick 16 17 p5.3/ain11/pwm2 ? sn8f27e65f (ac field , lqfp 32 pin ) : ? sn8f27e65 j (ac field , qfn 5x5 32 pin ) : ? sn8f27e65 l f ( d c field , lqfp 32 pin): ? sn8f27e65 lj ( d c field , qfn 5x5 32 pin): rst/p0.4 xout/p0.5 xin/p0.6 vss vddl vddl vdd avrefh 32 31 30 29 28 27 26 25 p0.3/utx/t1 1 o 24 p4.0/ain0 p0.2/urx/tc2 2 23 p4.1/ain1 p0.1/int1/tc1 3 22 p4.2/ain2 p0.0/int0/tc0 4 21 p4.3/ain3 p1.7/scs 5 20 p4.4/ain4 p1.6/sck 6 19 p4.5/ain5 p1.5/sdi 7 18 p4.6/ain6 p1.4/sdo 8 17 p4.7/ain7 9 10 11 12 13 14 15 16 p1.3/scl p1.2/sda p1.1/eida p1.0/eick p5.3/ain11/pw m2 p5.2/ain10/pwm1 p5.1/ain9/pwm0 p5.0/ain8 rst/p0.4 xout/p0.5 xin/p0.6 vss vdd vdd vdd avrefh 32 31 30 29 28 27 26 25 p0.3/utx/t1 1 o 24 p4.0/ain0 p0.2/urx/tc2 2 23 p4.1/ain1 p0.1/int1/tc1 3 22 p4.2/ain2 p0.0/in t0/tc0 4 21 p4.3/ain3 p1.7/scs 5 20 p4.4/ain4 p1.6/sck 6 19 p4.5/ain5 p1.5/sdi 7 18 p4.6/ain6 p1.4/sdo 8 17 p4.7/ain7 9 10 11 12 13 14 15 16 p1.3/scl p1.2/sda p1.1/eida p1.0/eick p5.3/ain11/pwm2 p5.2/a in10/pwm1 p5.1/ain9/pwm0 p5.0/ain8 ? SN8F27E64k (ac field , skdip 28 pin ) : ? SN8F27E64s (ac field , sop 28 pin ) : ? SN8F27E64 x (ac field , ssop 28 pin ) : ? SN8F27E64 l k ( d c field , skdip 28 pin ) : ? SN8F27E64 l s ( d c field , sop 28 pin ) : ? SN8F27E64 lx ( d c field , ssop 28 pin ) : vss 1 u 28 vddl xin/p0.6 2 27 vdd / avrefh xout/p0.5 3 26 p4.1/ain1 rst/p0.4 4 25 p4.2/ain2 p0.3/utx/t1 5 24 p4.3/ain3 p0.2/urx/tc2 6 23 p4.4/ain4 p0.1/int1/tc1 7 22 p4.5/ain5 p0.0/int0/tc0 8 21 p4.6/ain6 p1.6/sck 9 20 p4.7/ain7 p1.5/sdi 10 19 p5.0/ain8 p1.4/sdo 11 18 p5.1/ain9/pwm0 p1.3/scl 12 17 p5.2/ain10/pwm1 p1.2/sda 13 16 p5.3/ain11/pwm2 p1.1/eida 14 15 p1.0/eick vss 1 u 28 vdd xin/p0.6 2 27 vdd /avrefh xout/p0.5 3 26 p4.1/ain1 rst/p0.4 4 25 p4.2/ain2 p0.3/utx/t1 5 24 p4.3/ain3 p0.2/urx/tc2 6 23 p4.4/ain4 p0.1/int1/tc1 7 22 p4.5/ain5 p0.0/int0/tc0 8 21 p4.6/ain6 p1.6/sck 9 20 p4.7/ain7 p1.5/sdi 10 19 p5.0/ain8 p1.4/sdo 11 18 p5.1/ain9/pwm0 p1.3/scl 12 17 p5.2/ain10/pwm1 p1.2/sda 13 16 p5.3/ain11/pwm2 p1.1/eida 14 15 p1.0/eick
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 12 version 1. 4 ? SN8F27E64 j (ac field , qfn 4x4 28 pin ) : ? SN8F27E64 lj ( d c field , qfn 4x4 28 pin ) : rst/p0.4 xout/p0.5 xin/p0.6 vss vddl vdd /avrefh p4.1/ain1 28 27 26 25 24 23 22 p0.3/utx/t1 1 o 21 p4.2/ain2 p0.2/urx/tc 2 2 20 p4.3/ain3 p0.1/int1/tc1 3 19 p4.4/ain4 p0.0/int0/tc0 4 18 p4.5/ain5 p1.6/sck 5 17 p4.6/ain6 p1.5/sdi 6 16 p4.7/ain7 p1.4/sdo 7 15 p5.0/ain8 8 9 10 11 12 13 14 p1.3/scl p1.2/sda p1.1/eida p1.0 /eick p5.3/ain11/pwm2 p5.2/ain10/pwm1 p5.1/ain9/pwm0 rst/p0.4 xout/p0.5 xin/p0.6 vss vdd vdd /avrefh p4.1/ain1 28 27 26 25 24 23 22 p0.3/utx/t1 1 o 21 p4.2/ain2 p0.2/urx/tc2 2 20 p4.3/ain3 p0.1/int1/tc1 3 19 p4.4/ain4 p0.0/int0/tc0 4 18 p4.5/ain5 p1.6/sck 5 17 p4.6/ain6 p1.5/sdi 6 16 p4.7/ain7 p1.4/sdo 7 15 p5.0/ain8 8 9 10 11 12 13 14 p1.3/scl p1.2/sda p1.1/eida p1.0/eick p5.3/ain11/pwm2 p5.2/ain10/pwm1 p5.1/ain9/pwm0 ? s n8f27e62 p (ac field , dip 20 pin ) : ? sn8f27e62s (ac field , sop 20 pin ) : ? sn8f27e62l p (dc field , dip 20 pin ) : ? sn8f27e62ls (dc field , sop 20 pin ) : vss 1 u 20 vddl xin/p0.6 2 19 vdd /avrefh xout/p0.5 3 18 p4.3/ain3 rst/p0.4 4 17 p4.4/ain4 p0.3/utx/t1 5 16 p4.5/ain5 p0.2/urx/tc2 6 15 p4.6/ain6 p0.0/int0/tc0 7 14 p4.7/ain7 p1.1/eida 8 13 p5.0/ain8 p1.0/eick 9 12 p5.1/ain9/pwm0 p5.3/ain11/pwm2 10 11 p5.2/ain10/pwm1 vss 1 u 20 vdd xin/p0.6 2 19 vdd /avrefh xout/p0.5 3 18 p4.3/ain3 rst/p0.4 4 1 7 p4.4/ain4 p0.3/utx/t1 5 16 p4.5/ain5 p0.2/urx/tc2 6 15 p4.6/ain6 p0.0/int0/tc0 7 14 p4.7/ain7 p1.1/eida 8 13 p5.0/ain8 p1.0/eick 9 12 p5.1/ain9/pwm0 p5.3/ain11/pwm2 10 11 p5.2/ain10/pwm1
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 13 version 1. 4 1.4 pin descriptions pin name type description vdd , vss p power supply input pins for digital and analog circuit. vddl p low voltage power pin. connect 0.1uf capacitor to vss. avrefh p adc high reference voltage input pin. rst/p0.4 i/o rst: system external reset input pin. schmitt trigger structure, ac tive low, normal stay to high. p0.4: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. xin/p0.6 i/o xin: oscillator input pin while external oscillator enable (crystal and rc). p0.6: b i - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. xout/p0.5 i/o xout: oscillator output pin while external crystal enable. p0.5: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. p0.0/int0/ tc0 i/o p0.0: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. int0: external interrupt 0 input pin. tc0: tc0 event counter input pi n. p0.1/int1/ tc1 i/o p0.1: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. int1: external interrupt 1 input pin. tc1: tc1 event counter input pin. p0.2/urx/ tc2 i/o p0.2: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. tc2: tc2 event counter input pin. urx: uart receive input pin. p0.3/utx/t1 i/o p0.3: bi - direction pin. schmitt tri gger structure as input mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. utx: uart transmit output pin. t1: t1 event counter input pin. p1.0/eick i/o p1.0: bi - direction pin. schmitt trigger structure as inp ut mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. eick: embedded ice clock pin. p1.1/eida i/o p1.1: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. eida: embedded ice data pin. p1.2/sda i/o p1.2: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. sda: msp data pin. p 1.3/scl i/o p1.3: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. scl: msp clock pin. p1.4/sdo i/o p1.4: bi - direction pin. schmitt trigger structure as inpu t mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. sdo: sio data output pin. p1.5/sdi i/o p1.5: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. progr ammable open - drain structure. sdi: sio data input pin. p1.6/sck i/o p1.6: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. sck: sio clock pin. p1.7/scs i /o p1.7: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. level change wake - up. programmable open - drain structure. scs: sio bus control pin. p4.0/ain0 i/o p4.0: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain0: adc channel 0 input pin. p4.1/ain1 i/o p4.1: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain1: adc channel 1 input pin. p4.2/ain2 i/o p4.2: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain2: adc channel 2 input pin. p4.3/ain3 i/o p4.3: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain3: adc channel 3 input pin. p4.4/ain4 i/o p4. 4: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 14 version 1. 4 ain4: adc channel 4 input pin. p4.5/ain5 i/o p4.5: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain5: adc channel 5 i nput pin. p4.6/ain6 i/o p4.6: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain6: adc channel 6 input pin. p4.7/ain7 i/o p4.7: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resiste rs. ain7: adc channel 7 input pin. p5.0/ain8 i/o p5.0: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain8: adc channel 8 input pin. p5.1/ain9/ pwm0 i/o p5.1: bi - direction pin. schmitt trigger structure as in put mode. built - in pull - up resisters. ain9: adc channel 9 input pin. pwm0: pwm 0 output pin. p5.2/ain10/ pwm1 i/o p5.2: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain10: adc channel 10 input pin. pwm 1: pwm 1 output pin. p5.3/ain11/ pwm2 i/o p5.3: bi - direction pin. schmitt trigger structure as input mode. built - in pull - up resisters. ain11: adc channel 11 input pin. pwm2: pwm 2 output pin. 1.5 pin circuit diagrams ? normal b i - direction i/o p in. ? bi - direction i/o p in s hared with s pecific d igital i nput f unction, e.g. int0, e vent counter, sio, msp, uart ? bi - direction i/o p in s hared with s pecific d igital o utput f unction, e.g. pwm, sio, msp, uar t p u l l - u p r e s i s t o r o u t p u t l a t c h p i n p n u r p n m i / o i n p u t b u s i / o o u t p u t b u s p n m p u l l - u p r e s i s t o r o u t p u t l a t c h p i n p n u r p n m s p e c i f i c i n p u t b u s o u t p u t b u s p n m s p e c i f i c i n p u t f u n c t i o n c o n t r o l b i t i o i n p u t b u s * . s p e c i f i c o u t p u t f u n c t i o n c o n t r o l b i t * . s o m e s p e c i f i c f u n c t i o n s s w i t c h i / o d i r e c t i o n d i r e c t l y , n o t t h r o u g h p n m r e g i s t e r . p u l l - u p r e s i s t o r o u t p u t l a t c h p i n p n u r p n m o u t p u t b u s p n m i o i n p u t b u s s p e c i f i c o u t p u t f u n c t i o n c o n t r o l b i t s p e c i f i c o u t p u t b u s * . s p e c i f i c o u t p u t f u n c t i o n c o n t r o l b i t * . s o m e s p e c i f i c f u n c t i o n s s w i t c h i / o d i r e c t i o n d i r e c t l y , n o t t h r o u g h p n m r e g i s t e r .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 15 version 1. 4 ? bi - direction i/o p in s hared with s pecific a nalog i nput f unction, e.g. xin, adc ? bi - direction i/o p in s hared with s pecific a nalog o utput f unction, e.g. xout p u l l - u p r e s i s t o r o u t p u t l a t c h p i n p n u r p n m i / o i n p u t b u s i / o o u t p u t b u s p n m * . s p e c i f i c a n a l o g f u n c t i o n c o n t r o l b i t a n a l o g i p i n p u t t e r m i n a l * . s o m e s p e c i f i c f u n c t i o n s s w i t c h i / o d i r e c t i o n d i r e c t l y , n o t t h r o u g h p n m r e g i s t e r . p u l l - u p r e s i s t o r o u t p u t l a t c h p i n p n u r p n m p n m i / o i n p u t b u s i / o o u t p u t b u s * . s p e c i f i c a n a l o g f u n c t i o n c o n t r o l b i t a n a l o g i p o u t p u t t e r m i n a l * . s o m e s p e c i f i c f u n c t i o n s s w i t c h i / o d i r e c t i o n d i r e c t l y , n o t t h r o u g h p n m r e g i s t e r .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 16 version 1. 4 2 2 2 central processor unit (cpu) 2.1 program memory ( flash rom) ? 6k word s flash rom address rom comment 0000h reset vector reset vector 0001h general purpose area user program . 0007h 0008h wake interrupt vector interrupt vector 0009h int0 interrupt vector 000ah int1 interrupt vector 000bh t0 interrupt vector 000ch tc0 interrupt vector 000dh tc1 interrupt vector 000eh tc2 interrupt vector 000fh t1 interrupt vector 0010h adc interrupt vector 0011h sio interrupt vector 0012h i2c interr upt vector 0013h uart rx interrupt vector 0014h uart tx interrupt vector 0015h general purpose area user program . . . . end of user program 17 f8 h reserved 17 f 9 h . 17 f d h 17 fe h 17ffh the rom includes reset vector, interru pt vector, general purpose area and reserved area. the reset vector is program beginning address. the interrupt vector is the head of interrupt service routine when any interrupt occurring. the general purpose area is main program area including main loop, sub - routines and data table. ? 0x0000 reset vector: program counter points to 0x0000 after any reset events (power on reset, reset pin reset, watchdog reset, lvd reset). ? 0x0001~0x0007: general purpose area to process system reset operation. ? 0x0008~0x00 14: multi interrupt vector area. each of interrupt events has a unique interrupt vector. ? 0x0015~0x1 77f : general purpose area for user program and isp ( eeprom function ) . ? 0x1780~0x17 f7 : general purpose area for user program . do not execute isp. ? 0x17 f 8~0x1 7ff: reserved area. do not execute isp. ? rom security rule is even address rom data protected and outputs 0x0000.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 17 version 1. 4 2.1.1 reset vector (0000h) a one - word vector address area is used to execute system reset. ? power on reset (por=1). ? watchdog reset (wdt=1). ? ex ternal reset (rst=1). after power on reset , external reset or watchdog timer overflow reset , then the chip will restart the program from address 0000h and all system registers will be set as default values. it is easy to know reset status from por, wdt, and rst flags of pflag register. the following example shows the way to define the reset vector in the program memory. ? example : defining reset vector org 0 ; 0000h jmp start ; jump to user program address. org 15h start: ; 00 1 5h, the head of user program. endp ; end of program ? note: the head of user program should skip interrupt vector area to avoid program execution error.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 18 version 1. 4 2.1.2 interrupt vector (0008h ~0014h ) a 1 3 - word vector address area is used to execute interrupt request. if any interrupt service executes, the program counter (pc) value is stored in stack buffer and jump to 0008h ~0014h of program memory to execute the vectored interrupt. th is i nterrupt is multi - vector and e ach of interrupts points to unique vector. users have to define the interrupt vector . the following example shows the way to define the interrupt vector in the program memory. ? note: the push and pop operations arent through instruction (push, pop) and can executed save and load acc and working registers (0x80~0x8f) by hardware automatically . rom priority 0008h wake interrupt vector 1 0009h int0 interrupt vector 2 000ah int1 interrupt vector 3 000bh t0 interrupt vector 4 000ch tc0 interrupt vector 5 000dh tc1 interrupt vector 6 000eh tc2 interrupt vector 7 000fh t1 interrupt vector 8 0010h adc interrupt vector 9 0011h sio interrupt vector 10 0012h msp interrupt vector 11 0013h uart rx interrupt vector 12 0014h uart tx interrupt vector 13 when o ne interrupt request occurs, and the program counter points to the correlative vector to execute interrupt service routine. if wake interrupt occurs, the program counter points to org 8. if int0 interrupt occurs, the program counter points to org 9 . in normal condition, several interrupt requests happen at the same time. so the priority of interrupt sources is very important, or the system doesnt know which interrupt is processed first. the interrupt priority is follow vector sequence. org 8 is prior ity 1. org 9 is priority 2 . in the case, the interrupt processing priority is as following. if wake, t0, tc2, t1 and sio interrupt requests happen at the same time, the system processing interrupt sequence is wake, t0, tc2, t 1 , and then sio. the system pr ocesses wake interrupt service routine first, and then processes t0 interrupt routineuntil finishing processing all interrupt requests . ? example : interrup t request occurrence sequence: (2~8 interrupt requests occur during wake interrupt service routine execution.) 1 2 3 4 5 6 7 8 wake adc tc1 t0 sio int0 t1 uart rx interrupt processing sequence: 1 2 3 4 5 6 7 8 wake int0 t0 tc1 t1 adc s io uart rx
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 19 version 1. 4 ? example: defining interrupt vector. the interrupt service routine is following user program. .code org 0 ; 0000h jmp start ; jump to user program address. org 8 ; interrupt vector, 0008h. jmp isr_wake ; jump to interrupt service routine address. jmp isr_int0 jmp isr_int1 jmp isr_t0 jmp isr_tc0 jmp isr_tc1 jmp isr_tc2 jmp isr_t1 jmp isr_adc jmp isr_sio jmp isr_msp jmp isr_uart_rx jmp isr_uart_tx org 15 h start: ; 0015h, the head of user program. isr_wake: ; the head of interrupt service routine. ; save acc and 0x80~0x8f register to buffers. ; load acc and 0x80~0x8f register from buffers. reti ; end of interrupt service routine. isr_int0: ; ; save acc and 0x80~0x8f register to buffers. ; load acc and 0x80~0x8f register from buffers. reti ; end of interrupt service routine. isr_uart_tx: ; ; save acc and 0x80~0x8f register to buffers. ; load acc and 0x80~0x8f register from buffers. re ti ; end of interrupt service routine. endp ; end of program. ? note: it is easy to understand the rules of sonix program from demo programs given above. these points are as following: 1. the address 0000h is a jmp instruction to make the pro gram starts from the beginning . 2. the address 0008h~0014h is interrupt vector. 3. user s program is a loop routine for main purpose application.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 20 version 1. 4 2.1.3 look - up table description in the roms data lookup function, y register is pointed to middle byte address ( bi t 8~bit 15 ) and z register is pointed to low byte address ( bit 0~bit 7 ) of rom. after movc instruction executed, the low - byte data will be stored in acc and high - byte data stored in r register. ? example: to look up the rom data located table1. b0mov y , #table1$m ; to set lookup table1s middle address ; to set lookup table1s low address. ; increment the index address for next address . incms z ; z+1 jmp @f ; z is n ot overflow . incms y ; z overflow (ffh ? 00), ? y= y+1 nop ; ; @@: movc ; to lookup data, r = 51h, acc = 05h. ? note : the y register will not inc rease automatically when z register cross es boundary from 0xff to 0x00. therefore, user must take care such situation to avoid loo k - up table errors. if z register is overflow, y register must be added one. the following inc_yz macro shows a simple method t o process y and z registers automatically. ? example: inc_yz macro . inc_yz macro incms z ; z+1 jmp @f ; not overflow incms y ; y+1 nop ; not overflow @@: endm
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 21 version 1. 4 ? example: modify above example by inc_yz macro . b0 mov y, #table1$m ; to set lookup table1s middle address ; to set lookup table1s low address. inc_yz ; increment the index address for next address . ; @@: movc ; to lookup data, r = 51h, acc = 05h. be careful if carry happen. ? exa mple: increase y and z register by b0add/add instruction . b0mov y, #table1$m ; to set lookup tables middle address. ; to set lookup tables low address. b0mov a, buf ; z = z + buf. b0add z, a b0bts1 fc ; check the carry flag. jmp getdata ; fc = 0 incms y ; fc = 1. y+1. nop getdata: ; movc ; to lookup data. if buf = 0, data is 0x0035 ; if buf = 1, data is 0x5105 ; if buf = 2, data is 0x2012
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 22 version 1. 4 2.1.4 jump table description the jump table operation is one of mu l ti - address jumping function . add low - byte program counter (pcl) and acc value to get one new pcl. if pcl is overflow after pcl+acc, pch adds one automatically. the new program counter (pc) points to a series jump instructions as a listing table. i t is easy to make a mu l ti - jump program depends on the value of the accumulator (a) . ? note : pch only support pc up counting r esult and doesn t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl C acc, pch keeps value and not change. ? example: jump table. org 0x0100 ; the jump table is from the head of the rom bound ary b0add pcl, a ; pcl = pcl + acc, pch + 1 when pcl overflow occurs . jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point s onix provides a macro for safe jump table function. this macro will check the rom boundary and move the jump table to the right position automatically. the side effect of this macro maybe wastes some rom size. ? example: if jump table crosses over rom bou ndary will cause errors. @jmp_a macro val if (($+1) !& 0xff00) !!= (($+(val)) !& 0xff00) jmp ($ | 0xff) org ($ | 0xff) endif add pcl, a endm ? note: val is the number of the jump table listing number.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 23 version 1. 4 ? example: @jmp_a applica tion in sonix macro file called macro3.h . b0mov a, buf0 ; @jmp_a macro will adjust the jump table routine begin from next ram boundary (0x0 100). ? example: @jmp_a operation. ; before compiling program. rom address b0mov a, buf0 ; ; after compiling program. rom address b0mov a, buf0 ;
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 24 version 1. 4 2.1.5 checksum calculation the last rom address are reserved area. user should avoid these addresses (last address) when calculate the checksum value. ? example: the demo program shows how to calc ulated checksum from 00h to the end of users code . mov a,#end_user_code$l b0mov end_addr1, a ; s ave low end address to end_addr1 mov a,#end_user_code$m b0mov end_addr2, a ; s ave middle end address to end_addr2 clr y ; s et y to 00h clr z ; s e t z to 00h @@: movc b0bset fc ; c lear c f lag add data1, a ; a dd a to data1 mov a, r adc data2, a ; a dd r to data2 jmp end_check ; c heck if the yz address = the end of code aaa: incms z ; z=z+1 jmp @b ; if z != 00h calculate to n ext address jmp y_add_1 ; i f z = 00h increase y end_check: mov a, end_addr1 cmprs a, z ; c heck if z = low end address jmp aaa ; i f not jump to checksum calculate mov a, end_addr2 cmprs a, y ; i f yes, check if y = middle end address jmp aaa ; i f not jump to checksum calculate jmp checksum_end ; i f yes checksum calculated is done. y_add_1: incms y ; i ncrease y nop jmp @b ; j ump to checksum calculate checksum_end: end_user_code: ; label of program en d
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 25 version 1. 4 2.2 data memory (ram) ? 512 x 8 - bit ram bank address ram location comment bank 0 000h general purpose area ram bank 0 ... ... 07fh 080h system register ... 0ffh end of bank 0 bank 1 100h general purpose area ram bank 1 1ffh end of bank 1 bank 2 200h general purpose area ram bank 2 27fh end of bank 2 the 512 - byte general purpose ram is separated into bank0, bank1 and bank2. accessing the three banks ram is controlled by rbank register. when rba nk = 0, the program controls bank 0 ram directly. when rbank = 1, the program controls bank 1 ram directly. when rbank = 2, the program controls bank 2 ram directly. under one bank condition and need to access the other bank ram, setup the rbank register i s necessary. when interrupt occurs, rbank register is saved, and ram bank is still last condition. user can select ram bank through setup rbank register during processing interrupt service routine. when reti is executed to leave interrupt operation, rbank register is reloaded, and ran bank returns to last condition. sonix provides bank 0 type instructions (e.g. b0mov, b0add, b0bts1, b0bset ) to control bank 0 ram in non - zero ram bank condition directly. ? example: access bank 0 ram in bank 1 condition. mo ve bank 0 ram (wk00) value to bank 1 ram (wk01). ; bank 1 (rbank = 1) b0mov a , wk00 ; use bank 0 type instruction to access bank 0 ram. mov wk01,a ? note: 1. for multi - bank ram program, it is not easy to control ram bank selection. users have t o take care the rbank condition very carefully , especially for interrupt service routine. the system wont save the rbank and switch ram bank to bank 0, so these controls must be through program. it is a good to use bank 0 type instruction to process the s ituations . 2. the 190h, 191h of ram address doesn t support directly addressing mode to access ram but support indirectly addressing mode @hl/@yz.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 26 version 1. 4 2.2.1 system register 2.2.1.1 system register table 0 1 2 3 4 5 6 7 8 9 a b c d e f 8 l h r z y x pflag rbank w0 w1 w2 w3 w4 w5 w6 w7 9 @hl @yz - pcl pch oscm wdtr intrq0 intrq1 - inten0 inten1 p0oc p1oc p1w pedge a p0m p1m - - p4m p5m p0 p1 - - p4 p5 p0ur p1ur - - b p4ur p5ur t0m t0c tc0m tc0c tc0r tc0d tc1m tc1c tc1r tc1d tc2m tc2c tc2r tc2d c t1m t1cl t1ch c ptm cptcl cptch p4con p5con adm adb adr adt - - - - d - - - - - - - - - - - pecmd pe roml pe romh pe raml peram cnt e siom sior siob sioc urtx urrx urcr utxd urxd - msp stat mspm1 mspm2 msp buf msp adr stkp f stk 7l stk 7h stk 6l stk 6h stk 5l st k5h stk 4l stk 4h stk3 l stk3 h stk2 l stk2 h stk1 l stk1 h stk0 l stk0 h 2.2.1.2 system register description h, l = working, @ hl addressing register. y, z = working, @yz and rom addressing register. r = working register and rom look - up data buffer. pflag = s pecial flag register. x = working and rom address register w0~w7= working register rbank = ram bank select register . p0oc,p1oc = open - drain control register. p1w = port 1 wakeup register . siom = sio mode control register. pedge = p0.0 , p0.1 edge direction register. sior = si o clock rate control register. urtx = uart transmit control register. siob = sio data buffer. urrx = uart receive control register. sioc = sio control register. urcr = uart baud rate control register. t1m = t1 mode register. utxd = uart transmit data b uff er . urxd = uart receive data buffer . t1ch, l = t1 counting registers. p4con,p5con = p4 , p5 configuration register. adm = adc mode register. adb = adc data buffer. adr = adc resolution select register. adt = adc offset calibration register. pedge = p0.0, p0.1, p0.2 edge direction register. intrq 0,1 = interrupt request register. inten 0,1 = interrupt enable register. wdtr = watchdog timer clear register. pnm = port n input/output mode register. pn = port n data buffer. pnur = port n pull - up resiste r control register. oscm = oscillator mode register. pch, pcl = program counter. t0m = t0 mode register. t0c = t0 counting register. t cn m = t cn mode register. t cn c = tc n counting register. tcnr = tcn auto - reload data buffer. tcnd= tcn duty control regi ster. cptm= capture timer control register cptcl,h= capture timer counting registers mspstat= msp status register mspbuf= msp buffer register. mspm1= msp mode register1 mspadr= msp address register. mspm2= msp mode register2 pecmd= isp command register . peram= isp ram mapping address perom= isp rom address peramcnt= isp ram programming counter register. @ hl = ram hl indirect addressing index pointer. @yz = ram yz indirect addressing index pointer. stkp = stack pointer buffer. stk0~stk 7 = stack 0 ~ st ack 7 buffer.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 27 version 1. 4 2.2.1.3 bit definition of system register address bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 r/w remarks 080h lbit7 lbit6 lbit5 lbit4 lbit3 lbit2 lbit1 lbit0 r/w l 081h hbit7 hbit6 hbit5 hbit4 hbit3 hbit2 hbit1 hbit0 r/w h 082h rbit7 rbit6 rbi t5 rbit4 rbit3 rbit2 rbit1 rbit0 r/w r 083h zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 r/w z 084h ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 r/w y 085h xbit7 xbit6 xbit5 xbit4 xbit3 xbit2 xbit1 xbit0 r/w x 086h por wdt rst stkov c dc z r/w p flag 087h rb a nks1 rb a nks0 r/w rbank 088h w0bit7 w0bit6 w0bit5 w0bit4 w0bit3 w0bit2 w0bit1 w0bit0 r/w w0 089h w1bit7 w1bit6 w1bit5 w1bit4 w1bit3 w1bit2 w1bit1 w1bit0 r/w w1 08ah w2bit7 w2bit6 w2bit5 w2bit4 w2bit3 w2bit2 w2bit1 w2bit0 r/w w2 08bh w3bit7 w3bit6 w3bit5 w3bit4 w3bit3 w3bit2 w3bit1 w3bit0 r/w w3 08ch w4bit7 w4bit6 w4bit5 w4bit4 w4bit3 w4bit2 w4bit1 w4bit0 r/w w4 08dh w5bit7 w5bit6 w5bit5 w5bit4 w5bit3 w5bit2 w5bit1 w5bit0 r/w w5 08eh w6bit7 w6bit6 w6bit5 w6bit4 w6bit3 w6bit2 w6bit1 w6bit0 r/w w6 08fh w7bit7 w7bit6 w7bit5 w7bit4 w7bit3 w7bit2 w7bit1 w7bit0 r/w w7 090h @hl7 @hl6 @hl5 @hl4 @hl3 @hl2 @hl1 @hl0 r/w @hl 091h @yz7 @yz6 @yz5 @yz4 @yz3 @yz2 @yz1 @yz0 r/w @yz 093h pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 r/w pcl 094h pc12 pc11 pc10 pc9 pc8 r/w pch 095h cpum1 cpum0 clkmd stphx r/w oscm 096h wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 w wdtr 097h adcirq t1irq tc2irq tc1irq tc0irq t0irq p01irq p00irq r/w intrq0 098h mspirq utxirq urxirq sioirq wakeirq r/w intrq1 09a h adcien t1ien tc2ien tc1ien tc0ien t0ien p01ien p00ien r/w inten0 09bh mspien utxien urxien sioien wakeien r/w inten1 09ch p03oc p02oc r/w p0oc 09dh p17oc p16oc p15oc p14oc p13oc p12oc p11oc p10oc r/w p1oc 09eh p17w p16w p15w p14w p13w p12w p 11w p10w r/w p1w 09fh p01g1 p01g0 p00g1 p00g0 r/w pedge 0a0h p06m p05m p04m p03m p02m p01m p00m r/w p0m 0a1h p17m p16m p15m p14m p13m p12m p11m p10m r/w p1m 0a4h p47m p46m p45m p44m p43m p42m p41m p40m r/w p4m 0a5h p53m p52m p51m p50m r/w p5m 0a6h p06 p05 p04 p03 p02 p01 p00 r/w p0 0a7h p17 p16 p15 p14 p13 p12 p11 p10 r/w p1 0aah p47 p46 p45 p44 p43 p42 p41 p40 r/w p4 0abh p53 p52 p51 p50 r/w p5 0ach p06ur p05ur p04ur p03ur p02ur p01ur p00ur r/w p0ur 0adh p17ur p16ur p15ur p14ur p1 3ur p12ur p11ur p10ur r/w p1ur 0b0h p47ur p46ur p45ur p44ur p43ur p42ur p41ur p40ur r/w p4ur 0b1h p53ur p52ur p51ur p50ur r/w p5ur 0b2h t0enb t0rate2 t0rate1 t0rate0 t0tb r/w t0m 0b3h t0c7 t0c6 t0c5 t0c4 t0c3 t0c2 t0c1 t0c0 r/w t0c 0b4h tc0enb tc0rate2 tc0rate1 tc0rate0 tc0cks1 tc0cks0 pwm0out r/w tc0m 0b5h tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 r/w tc0c 0b6h tc0r7 tc0r6 tc0r5 tc0r4 tc0r3 tc0r2 tc0r1 tc0r0 w tc0r 0b7h tc0d7 tc0d6 tc0d5 tc0d4 tc0d3 tc0d2 tc0d1 tc0d0 r/w tc0d 0b8h tc 1enb tc1rate2 tc1rate1 tc1rate0 tc1cks1 tc1cks0 pwm1out r/w tc1m 0b9h tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 r/w tc1c 0bah tc1r7 tc1r6 tc1r5 tc1r4 tc1r3 tc1r2 tc1r1 tc1r0 w tc1r 0bbh tc1d7 tc1d6 tc1d5 tc1d4 tc1d3 tc1d2 tc1d1 tc1d0 r/w tc1d 0b ch tc2enb tc2rate2 tc2rate1 tc2rate0 tc2cks1 tc2cks0 pwm2out r/w tc2m 0bdh tc2c7 tc2c6 tc2c5 tc2c4 tc2c3 tc2c2 tc2c1 tc2c0 r/w tc2c 0beh tc2r7 tc2r6 tc2r5 tc2r4 tc2r3 tc2r2 tc2r1 tc2r0 w tc2r 0bfh tc2d7 tc2d6 tc2d5 tc2d4 tc2d3 tc2d2 tc2d1 tc2d0 r/w tc2 d 0c0h t1enb t1rate2 t1rate1 t1rate0 t1cks r/w t1m 0c1h t1c7 t1c6 t1c5 t1c4 t1c3 t1c2 t1c1 t1c0 r/w t1cl 0c2h t1c15 t1c14 t1c13 t1c12 t1c11 t1c10 t1c9 t1c8 r/w t1ch 0c3h cpten cptmd cptstart cptg1 cptg0 r/w cptm 0c4h cptc7 cptc6 cptc5 cptc4 cptc 3 cptc2 cptc1 cptc0 r/w cptcl 0c5h cptc15 cptc14 cptc13 cptc12 cptc11 cptc10 cptc9 cptc8 r/w cptch 0c6h p4con7 p4con6 p4con5 p4con4 p4con3 p4con2 p4con1 p4con0 r/w p4con 0c7h p5con3 p5con2 p5con1 p5con0 r/w p5con 0c8h adenb ads eoc gchs chs3 chs2 c hs1 chs0 r/w adm 0c9h adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 r adb 0cah adcks1 adlen adcks0 adb1 adb0 r/w adr
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 28 version 1. 4 0cbh adts1 adts0 adt4 adt3 adt2 adt1 adt0 r/w adt 0dbh pecmd7 pecmd6 pecmd5 pecmd4 pecmd3 pecmd2 pecmd1 pecmd0 r/w pecmd 0dch peroml7 pe roml6 peroml5 peroml4 peroml3 peroml2 peroml1 peroml0 r/w peroml 0ddh peromh7 peromh6 peromh5 peromh4 peromh3 peromh2 peromh1 peromh0 r/w peromh 0deh peraml7 peraml6 peraml5 peraml4 peraml3 peraml2 peraml1 peraml0 r/w peraml 0dfh peramcn t7 peramcn t6 per amcn t5 peramcn t4 peramcn t3 peraml9 peraml8 r/w peramcnt 0e0h senb start srate1 srate0 mlsb sclkmd cpol cpha r/w siom 0e1h sior7 sior6 sior5 sior4 sior3 sior2 sior1 sior0 w sior 0e2h siob7 siob6 siob5 siob4 siob3 siob2 siob1 siob0 r/w siob 0e3h si obz scsen scsp r/w sioc 0e4h utxen utxpen utxps utxbrk urxbz utxbz r/w urtx 0e5h urxen urxpen urxps urxpc ufmer urs2 urs1 urs0 r/w urrx 0e6h urcr7 urcr6 urcr5 urcr4 urcr3 urcr2 urcr1 urcr0 r/w urcr 0e7h utxd7 utxd6 utxd5 utxd4 utxd3 utxd2 utxd1 utxd0 r/w utxd 0e8h urxd7 urxd6 urxd5 urxd4 urxd3 urxd2 urxd1 urxd0 r/w urxd 0eah - cke d _ a p s red _ wrt - bf r mspstat 0ebh wcol mspov mspenb ckp slrxckp mspwk - mspc r/w mspm1 0ech gcen ackstat ackdt acken rcen pen rsen sen r/w mspm2 0edh mspbuf7 mspbuf6 mspbuf5 mspbuf4 mspbuf3 mspbuf2 mspbuf1 mspbuf0 r/w mspbuf 0eeh mspadr7 mspadr6 mspadr5 mspadr4 mspadr3 mspadr2 mspadr1 mspadr0 r/w mspadr 0efh gie lvd24 lvd3 3 stkpb2 stkpb1 stkpb0 r/w stkp 0f0h s7pc7 s7pc6 s7pc5 s7pc4 s7pc3 s7pc2 s7pc1 s7pc0 r/w stk7 l 0f1h s7pc12 s7pc11 s7pc10 s7pc9 s7pc8 r/w stk7h 0f2h s6pc7 s6pc6 s6pc5 s6pc4 s6pc3 s6pc2 s6pc1 s6pc0 r/w stk6l 0f3h s6pc12 s6pc11 s6pc10 s6pc9 s6pc8 r/w stk6h 0f4h s5pc7 s5pc6 s5pc5 s5pc4 s5pc3 s5pc2 s5pc1 s5pc0 r/w stk5l 0f5h s5pc12 s5pc11 s5pc10 s5pc9 s5pc8 r/w stk5h 0f6h s4pc7 s4pc6 s4pc5 s4pc4 s4pc3 s4pc2 s4pc1 s4pc0 r/w stk4l 0f7h s4pc12 s4pc11 s4pc10 s4pc9 s4pc8 r/w stk4h 0f8h s3pc7 s3pc6 s3pc5 s3pc4 s3pc3 s3pc2 s3pc1 s3pc0 r/w stk3l 0f9h s3pc12 s3pc11 s3pc10 s3pc9 s3pc8 r/w stk3h 0fah s2pc7 s2pc6 s2pc5 s2pc4 s2pc3 s2pc2 s2pc1 s2pc0 r/w stk2l 0fbh s2pc12 s2pc11 s2pc10 s2pc9 s2pc8 r/w stk2h 0fch s1pc7 s1pc6 s1pc5 s1pc4 s1pc3 s1pc2 s1pc1 s1pc0 r/w stk1l 0fdh s1pc12 s1pc11 s1pc10 s1pc9 s1pc8 r/w stk1h 0feh s0pc7 s0pc6 s0pc5 s0pc4 s0pc3 s0pc2 s0pc1 s0pc0 r/w stk0l 0ffh s0pc12 s0pc11 s0pc10 s0pc9 s0pc8 r/w stk0h ? note: 1. to avoid system error, make sure to put all the 0 and 1 as it indicates in the above table . 2. all of register name s had been declared in sn8asm as sembler. 3. one - bit name had been declared in sn8asm assembler with f prefix code. 4. b0bset, b0bclr,bset,bclr instructions are only available to the r/w registers .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 29 version 1. 4 2.2.2 accumulator the acc is an 8 - bit data register responsible for transferring or ma nipulating data between alu and data memory. if the result of operating is zero (z) or there is carry (c or dc) occurrence, then these flags will be set to pflag register. acc is not in data memory (ram), so acc cant be access by b0mov instruction durin g the instant addressing mode. ? example: read and write acc value. ; read acc data and store in buf data memory mov buf, a ; write a immediate data into acc mov a, #0fh ; write acc data from buf data memory mov a, buf th e system will store acc and working registers ( 0x80 - 0x8f) by hardware automatically when interrupt executed. ? example: protect acc and working registers. .code int_service: ; save acc t o buffer. ; save working registers to buffer. ; load working registers form buffers. ; load acc form buffer. reti ; exit interrupt service vector
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 30 version 1. 4 2.2.3 program flag the pflag register contains the arithmetic status of alu operation, system reset status and lvd detecting s tatus. por, wdt, and rst bits indicate system reset status including power on reset, lvd reset, reset by external pin active and watchdog reset. c, dc, z bits indicate the result status of alu operation. lvd24, lvd3 3 bits indicate lvd detecting power volta ge status. 0 86 h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag por wdt rst stkov - c dc z read/write r r r r - r/w r/w r/w after reset - - - - - 0 0 0 bit 7 por: power on reset and lvd brown - out reset indicator. 0 = non - active. 1 = reset ac tive. lvd announces reset flag. bit 6 wdt: watchdog reset indicator. 0 = non - active. 1 = reset active. watchdog announces reset flag. bit 5 rst: external reset indicator. 0 = non - active. 1 = reset active. external reset announces reset flag. bit 4 stkov: stack overflow indicator. 0 = non - overflow. 1 = stack overflow. bit 2 c: carry flag 1 = a ddition with carry , subtraction without borrowing , rotation with shifting out logic 1 , comparison result 0. 0 = a ddition without carry , subtraction wi th borrowing signal , rotation with shifting out logic 0 , comparison result < 0. bit 1 dc: decimal carry flag 1 = a ddition with carry from low nibble , subtraction without borrow from high nibble. 0 = a ddition without carry from low nibble , subtraction w ith borrow from high nibble. bit 0 z: zero flag 1 = the result of an a rithmetic /logic/branch operation is zero . 0 = the result of an a rithmetic /logic/branch operation is not zero . 0 ef h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie lvd24 lvd 3 3 - - stkpb2 stkpb1 stkpb0 read/write r /w r r - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit 6 lvd24 : lvd24 low voltage detect indicator. 0 = vdd > lvd24 detect level. 1 = vdd < lvd24 detect level. bit 5 lvd3 3 : lvd3 3 low voltage detect indicator . 0 = vdd > lvd3 3 detect level. 1 = vdd < lvd3 3 detect level. ? note: refer to instruction set table for detailed information of c, dc and z flags.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 31 version 1. 4 2.2.4 program counter the program counter (pc) is a 1 3 - bit binary counter separated into the high - byte 5 a nd the low - byte 8 bits. this counter is responsible for pointing a location in order to fetch an instruction for kernel circuit. normally, the program counter is automatically incremented with each instruction during program execution. besides, it can be replaced with specific address by executing call or jmp instruction. when jmp or call instruction is executed, the destination address will be inserted to bit 0 ~ bit 12. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc - - - pc12 pc11 pc10 pc9 pc8 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 after reset - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 pch pcl ? one address skipping there are nine instructions (cmprs, incs, incms, decs, decms, bts0, bts1, b0bts0, b0bts1 ) with one address skipping function. if the result of these instructions is true, the pc will add 2 steps to skip next instruction. if the condition of bit test instruction is true, the pc will add 2 steps to skip next instruction. b0bts1 fc ; to skip , if carry_flag = 1 jmp c0step ; else jump to c0step. b0bts 0 f z ; to skip, if zero flag = 0. jmp c1step ; else jump to c1step. if the acc is equal to the immediate data or memory, the pc will add 2 steps to skip next instruction. cmprs a, #12h ; to skip, if acc = 12h. jmp c0step ; else jump to c0step.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 32 version 1. 4 if the destination increased by 1 , which results overflow of 0xff t o 0x00, the pc will add 2 steps to skip next instruction. incs instruction: incs buf0 jmp c0step ; jump to c0step if acc is not zero. c0step: nop incms instruction: incms buf0 jmp c0step ; jump to c0step if buf0 is not zero. c0step: nop if the destination decreased by 1 , which results underflow of 0x0 1 to 0x 00 , the pc will add 2 steps to skip next instruction. decs instruction: decs buf0 jmp c0step ; jump to c0step if acc is not zero. c0step: no p decms instruction: decms buf0 jmp c0step ; jump to c0step if buf0 is not zero. c0step: nop
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 33 version 1. 4 ? multi - address jumping users can jump a round the multi - address by either jmp instruction or add m, a instruction (m = pcl) to activate multi - address jumping function. program counter supports add m,a , adc m,a and b0add m,a instructions for carry to pch when pcl overflow automatically. for jump table or others applications, users can calculate pc value by the three instructions and d ont care pcl overflow problem. ? note : pch only support pc up counting result and doesn t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl C acc, pch keeps value and not change. ? example: if pc = 0323h (pch = 03h , pcl = 23h) ; pc = 0323h mov a, #28h b0mov pcl, a ; jump to address 0328h ; pc = 0328h mov a, #00h b0mov pcl, a ; jump to address 0300h ? example: if pc = 0323h (pch = 03h , pcl = 23h) ; pc = 0323 h b0add pcl, a ; pcl = pcl + acc, the pch cannot be changed. jmp a0point ; if acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 34 version 1. 4 2.2.5 h, l re gisters the h and l registers are the 8 - bit buffers. there are two major functions of these registers. ? c an be used as general working registers ? c an be used as ram data pointers with @hl register 081h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h hbit7 hbit6 hbit5 hbit4 hbit3 hbit2 hbit1 hbit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 080h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 l lbit7 lbit6 lbit5 lbit4 lbit3 lbit2 lbit1 lbit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - example: if want to read a data from ram address 20h of bank_0, it can use indirectly addressing mode to access data as following. b0mov h, #00h ; to set ram bank 0 for h register b0mov l, #20h ; to set l ocation 20h for l register b0mov a, @hl ; to read a data into acc example: clear general - purpose data memory area of bank 0 using @hl register. clr h ; h = 0, bank 0 b0mov l, #07fh ; l = 7fh, the last address of the data memory area clr_hl_buf: clr @hl ; clear @hl to be zero decms l ; l C
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 35 version 1. 4 2.2.6 x registers x register is an 8 - bit buffer and only general working register purpose . ? c an be used as general working registers 085h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 x xbit7 xbit6 xbit5 xbit4 xbit3 xbit2 xbit1 xbit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 2.2.7 y, z registers the y and z registers are the 8 - bit buffers. there are three major functions of these registers. ? c an be used as general working registers ? c an be used as ram data pointers with @yz register ? c an be used as rom data pointer with th e movc instruction for look - up table 084h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 y ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 083h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 z zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - example: uses y, z register as the data pointer to access data in the ram address 025h of bank0. b0mov y, #00h ; to set ram bank 0 for y register b0mov z, #25h ; to set location 25h for z register b0mov a, @yz ; to read a data into acc example: uses the y, z register as data pointer to clear the ram data. b0mov y, #0 ; y = 0, bank 0 b0mov z, #07fh ; z = 7 fh, the last address of the data memory area clr_yz_buf: clr @yz ; clear @yz to be zero decms z ; z C
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 36 version 1. 4 2.2.8 r register r register is an 8 - bit buffer. there are two major functions of the register. ? can be used as working register ? for store high - byte data of look - up table (movc instruction executed, the high - byte data of specified rom address will be stored in r register and the low - byte data will be stored in acc). 082h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - ? note: please refer to the look - up table description about r register look - up table application.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 37 version 1. 4 2.2.9 w registers w register includes w0~w7 8 - bit buffer s . there are two major functions of the register. ? c an be used as general working registers in assembl y language situation. ? c an be used as program buffers in c - language situation. 088h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w0 w0bit7 w0bit6 w0bit5 w0bit4 w0bit3 w0bit2 w0bit1 w0bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 089h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w1 w1bit7 w1bit6 w1bit5 w1bit4 w1bit3 w1bit2 w1bit1 w1bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 08ah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w2 w2bit7 w2bit6 w2bit5 w2bit4 w2bit3 w2bit2 w2bit1 w2bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 08bh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w3 w3bit7 w3bit6 w3bit5 w3bit4 w3bit3 w3bit2 w3bit1 w3bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 08ch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w4 w4bit7 w4bit6 w4bit5 w4bit4 w4bit3 w4bit2 w4bit1 w4bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 08dh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w5 w5bit7 w5bit6 w5bit5 w5bit4 w5bit3 w5bit2 w5bit1 w5bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 08eh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w6 w6bit7 w6bit6 w 6bit5 w6bit4 w6bit3 w6bit2 w6bit1 w6bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - 08fh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w7 w7bit7 w7bit6 w7bit5 w7bit4 w7bit3 w7bit2 w7bit1 w7bit0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset - - - - - - - - ? note: 1. in assembly language situation, w0~w7 can be used as general working registers. 2. in c - language situation, w0~w7 are reserved for c - compiler, and recommend not to access w0~w 7 by program strongly.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 38 version 1. 4 2.3 addressing mode 2.3.1 immediate addressing mode the immediate addressing mode uses an immediate data to set up the location in acc or specific ram. ? example: move the immediate data 12h to acc. mov a, #12h ; to set an immediate data 12h into acc. ? e xample: move the immediate data 12h to r register. b0mov r, #12h ; to set an immediate data 12h into r register. ? note: in immediate addressing mode application, the specific ram must be 0x80~0x8 f working register. 2.3.2 directly addressing mode the di rectly addressing mode moves the content of ram location in or out of acc. ? example: move 0x12 ram location data into acc. b0mov a, 12h ; to get a content of ram location 0x12 of bank 0 and save in acc. ? example: move acc data into 0x12 ram location. b0mov 12h, a ; to get a content of acc and save in ram location 12h of bank 0. 2.3.3 indirectly addressing mode the indirectly addressing mode is to access the memory by the data pointer registers (h/l, y/z). example: indirectly addressing mode with @hl r egister b0mov h, #0 ; to clear h register to access ram bank 0. b0mov l, #12h ; to set an immediate data 12h into l register. b0mov a, @hl ; use data pointer @hl reads a data from ram location ; 012h into acc. example: indirectly addressing m ode with @yz register b0mov y, #0 ; to clear y register to access ram bank 0. b0mov z, #12h ; to set an immediate data 12h into z register. b0mov a, @yz ; use data pointer @yz reads a data from ram location ; 012h into acc.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 39 version 1. 4 2.4 stack operation 2.4.1 overview the stack buffer has 8 - level. these buffers are designed to push and pop up program counters (pc) data when interrupt service routine and call instruction are executed. the stkp register is a pointer designed to point active level in order to push or pop up data from stack buffer. the stknh and stknl are the stack buffer s to store program counter (pc) data. 2.4.2 stack pointer the stack pointer (stkp) is a 3 - bit register to store the address used to access the stack b uffer, 13 - bit data memory ( stknh and stknl ) set aside for temporary storage of stack addresses. the two stack operations are writing to the top of the stack (push) and reading from the top of stack (pop). push operation decrements the stkp and the pop oper ation incre ments each time. that makes the stkp always point to the top address of stack buffer and write the last program counter value (pc) into the stack buffer. 0efh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie lvd24 lvd3 3 - - stkpb2 stk pb1 stkpb0 read/write r/w r r - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit[2:0] stkpbn: stack pointer (n = 0 ~ 2) bit 7 gie: global interrupt control bit. 0 = d isable. 1 = e nable. please refer to the interrupt chapter. ? example: stack pointer ( stkp) reset, we strongly recommended to clear the stack pointers in the beginning of the program. mov a, #0000 0 111b b0mov stkp, a ret / reti call / interrupt stkp = 7 stkp = 6 stkp = 5 stkp = 4 stack level stk7h stk6h stk5h stk4h stack buffer high byte pch stkp stk7l stk6l stk5l stk4l stack buffer low byte pcl stkp stkp - 1 stkp + 1 stkp = 3 stkp = 2 stkp = 1 stkp = 0 stk3l stk2l stk1l stk0l stk3h stk2h stk1h stk0h
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 40 version 1. 4 2.4.3 stack buffer the program counter (pc) value is stored in the stack buffer before a call instruction executed or duri ng interrupt service routine. stack operation is a lifo type (last in and first out). the stack pointer (stkp) and stack buffer (stknh and stknl) are located in the system register area bank 0. 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 s tknh - - - snpc12 snpc11 snpc10 snpc9 snpc8 read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknl snpc7 snpc6 snpc5 snpc4 snpc3 snpc2 snpc1 snpc0 read/write r/w r/w r/w r/w r/ w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 stkn = stknh , stknl (n = 7 ~ 0) 2.4.4 stack overflow indicator if stack pointer is normal and not overflow, the program execution is correct. if stack overflows, the program counter would be incorrect making program execution error. stkov bit is stack pointer overflow indicator to monitor stack pointer status. when stkov=0, stack pointer status is normal. if stkov=1, stack overflow occurs, and the program execution would be error. the program can take measures to rec over program execution from stack overflow situation through stkov bit. 0 86 h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag por wdt rst stkov - c dc z read/write r r r r - r/w r/w r/w after reset - - - - - 0 0 0 bit 4 stkov: stack overflow i ndicator. 0 = non - overflow. 1 = stack overflow. ? note: if stkov bit is set as stack overflowing, only system reset event can clear stkov bit, e.g. watchdog timer overflow, external reset pin low status or lvd reset. ? example: stack overflow protection through watchdog reset. watchdog timer must be enabled. main: ? example: stack overflow protection through external reset. external reset function must be enabled, and one gpio pin (output mode) connects to external reset pin. main:
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 41 version 1. 4 2.4.5 stack operation example the two kinds of stack - save operations refer to the stack point er (stkp) and write the content of program counter (pc) to the stack buffer are call instruction and interrupt service. under each condition, the stkp decre ases and points to the next available stack location. the stack buffer stores the program counter ab out the op - code address. the stack - save operation is as the following table. stack level stk p register stack buffer stkov description stkpb2 stkpb1 stkpb0 high byte low byte 0 1 1 1 free free 0 - 1 1 1 0 stk0h stk0l 0 - 2 1 0 1 stk1h stk1l 0 - 3 1 0 0 stk2h stk2l 0 - 4 0 1 1 stk3h stk3l 0 - 5 0 1 0 stk4h stk4l 0 - 6 0 0 1 stk5h stk5l 0 - 7 0 0 0 stk6h stk6l 0 - 8 1 1 1 stk7h stk7l 0 - > 8 1 1 0 - - 1 stack over, error there are stack - restore operation s correspond to e ach push operation to restore the program counter (pc). the reti instruction uses for interrupt service routine. the ret instruction is for call instruction. when a pop operation occurs, the stkp is incre mented and points to the next free stack location. the stack buffer restor es the last program counter (pc) to the program counter registers. the stack - restore operation is as the following table. stack level stk p register stack buffer stkov description stkpb2 stkpb1 stkpb0 high byte low byte 8 1 1 1 stk7h stk7l 0 - 7 0 0 0 stk6h stk6l 0 - 6 0 0 1 stk5h stk5l 0 - 5 0 1 0 stk4h stk4l 0 - 4 0 1 1 stk3h stk3l 0 - 3 1 0 0 stk2h stk2l 0 - 2 1 0 1 stk1h stk1l 0 - 1 1 1 0 stk0h stk0l 0 - 0 1 1 1 free free 0 - ? note: when stack overflow occurs, the system detects the condi tion and set stkov flag (logic 1). stkov flag cant be cleared by program.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 42 version 1. 4 2.5 code option table the code option is the system hardware configurations including oscillator type, noise filter option, watchdog timer operation, lvd option, reset pin option and flash rom security control. the code option items are as following table: code option content function description high_clk ihrc_16m high speed internal 16mhz rc. xin/xout pins are bi - direction gpio mode. ihrc_rtc high speed internal 16mhz rc. x in/xout pins are connected to external 32768hz crystal. rc low cost rc for external high clock oscillator . xin pin is connected to rc oscillator. xout pin is bi - direction gpio mode. 32k xtal 12m xtal 4m xtal
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 43 version 1. 4 2.5.1 fcpu code option fcpu means instruction cycle whose clock source includes high/low speed oscillator in different operating modes. high_fcpu and low_fcpu code options select instruction cycle pre - scaler to decide instruction cycle rate. in normal mode (high speed clock), the system clock source is high speed oscillator , and fcpu clock rate has eight options including fhosc/1, fhosc/2, fhosc/4, fhosc/8, fhosc/16, fhosc/32, fhosc/64, fhosc/128. in slow mode (low speed clock), the system clock source is internal low speed rc oscillator, and the fcpu including flosc/1, flosc/2, flosc/4, flosc/8. 2.5.2 reset_pin code option the reset pin is shared with general input only pin controlled by code option. ? reset : the reset pin is external reset function . w hen falling edge trigger occurring, the system will be reset. ? p04 : set reset pin to general bi - direction pin (p0.4). the external reset function is disabled and the pin is bi - direction pin. 2.5.3 security cod e option security code option is flash rom protection. when enable security code option, the rom code is secured and not dumped complete rom contents. 2.5.4 noise filter code option noise filter code option is a power noise filter manner to reduce noisy effect of system clock. if noise filter enable, in high noisy environment, enable noise filter, enable watchdog timer and select a good lvd level can make whole system work well and avoid error event occurrence.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 44 version 1. 4 3 3 3 reset 3.1 overview the system would be reset in thr ee conditions as following. ? power on reset ? watchdog reset ? brown out reset ? external reset (only supports external reset pin enable situation) when any reset condition occurs, all system registers keep initial status, program stops and program counter is cleared. after reset status released, the system boots up and program starts to execute from org 0. the por , wdt and rst flags indicate system reset status. the system can depend on por , wdt and rst status and go to different paths by program. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag por wdt rst stkov - c dc z read/write r r r r - r/w r/w r/w after reset - - - - - 0 0 0 bit 7 por: power on reset and lvd brown - out reset indicator. 0 = non - active. 1 = reset active. lvd announces re set flag. bit 6 wdt: watchdog reset indicator. 0 = non - active. 1 = reset active. watchdog announces reset flag. bit 5 rst: external reset indicator. 0 = non - active. 1 = reset active. external reset announces reset flag. finishing any reset sequenc e needs some time. the system provides complete procedure s to make the power on reset successful. for different oscillator types, the reset time is different. that causes the vdd rise rate and start - up time of different oscillator is not fixed. rc type osc illator s start - up time is very short, but the crystal type is longer. under client terminal application, users have to take care the power on reset time for the master terminal requirement. the reset timing diagram is as following. vdd vss vdd vss watchdog normal run watchdog stop system normal run system stop lvd detect level external reset low detect external reset high detect watchdog overflow watchdog reset delay time external reset delay time power on delay time power external reset watchdog reset system status
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 45 version 1. 4 3.2 power on reset the power on reset depend no lvd operation for most power - up situations. the power supplying to system is a rising curve and needs some time to achieve the normal voltage. power on reset sequence is as following. ? power - up: system detects the power voltage up and waits for power stable. ? external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset status and waits external reset pin released. ? system initialization: all system registers is set as initial conditions and system is ready. ? oscillator warm up: oscillator operation is successfully and supply to system clock. ? program executing: power on sequence is finished and program executes fro m org 0. 3.3 watchdog reset watchdog reset is a system protection. in normal condition, system works well and clear s watchdog timer by program. under error condition, system is in unknown situation and watchdog can t be clear by program before watchdog timer overflow. watchdog timer overflow occurs and the system is reset. after watchdog reset, the system restarts and returns normal mode. watchdog reset sequence is as following. ? watchdog timer status: system checks watchdog timer overflow status. if watchdog timer overflow occurs, the system is reset. ? system initialization: all system registers is set as initial conditions and system is ready. ? oscillator warm up: oscillator operation is successfully and supply to system clock. ? program executing: power on se quence is finished and program executes from org 0. watchdog timer application note is as following. ? before clearing watchdog timer, check i/o status and check ram contents can improve system error. ? dont clear watchdog timer in interrupt vector and inte rrupt service routine. that can improve main routine fail. ? clearing watchdog timer program is only at one part of the program. this way is the best structure to enhance the watchdog timer function. ? note: please refer to the watchdog timer about watchdo g timer detail information . 3.4 brown out reset the brown out reset is a power dropping condition. the power drops from normal voltage to low voltage by external factors (e.g. eft interference or external loading changed). the brown out reset would make the system not work well or executing program error. brown out reset diagram vdd vss v1 v2 v3 system work well area system work error area
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 46 version 1. 4 the power dropping might through the voltage range that s the system dead - band. the dead - band means the power range cant offer the system minimum ope ration power requirement . the above diagram is a typical brown out reset diagram . there is a serious noise under the vdd, and vdd voltage drops very deep. there is a dotted line to separate the system working area. the above area is the system work well ar ea. the below area is the system work error area called dead - band. v1 does nt touch the below area and not effect the system operation. but the v2 and v3 is under the below area and may induce the system error occurrence. let system under dead - band include s some condition s. dc application: the power source of dc application is usually using battery. when low battery condition and mcu drive any loading, the power drops and keeps in dead - band. under the situation, the power wont drop deeper and not touch th e system reset voltage. that make s the system under dead - band. ac application: in ac power application, the dc power is regulated from ac power source. this kind of power usually couples with ac noise that makes the dc power dirty. or the external loading is very heavy, e.g. driving motor. the loading operating induces noise and overlaps with the dc power. vdd drops by the noise, and the system works under unstable power situation. the power on duration and power down duration are longer in ac application. the system power on sequence protects the power on successful, but the power down situation is like dc low battery condition. when turn off the ac power, the vdd drops slowly and through the dead - band for a while. 3.4.1 the system operating voltage to improv e the brown out reset needs to know the system minimum operating voltage which is depend on the system executing rate and power level. different system executing rates have different system minimum operating voltage. the electrical characteristic section s hows the system voltage to executing rate relationship . normally the system operation voltage area is higher than the system reset voltage to vdd, and the reset voltage is decided by lvd detect level. the system minimum opera ting voltage rises when the system executing rate upper even higher than system reset voltage. the dead - band definition is the system minimum operating voltage above the system reset voltage. 3.4.2 low voltage detector (lvd) vdd (v) system rate (fcpu) system mini. operating voltage. system reset voltage. dead-band area normal operating area reset area vdd vss system normal run system stop lvd detect voltage power on delay time power system status power is below lvd detect voltage and system reset.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 47 version 1. 4 th e lvd (low voltage detector) is built - in sonix 8 - bit mcu to be brown out reset protection. when the vdd drops and is below lvd detect voltage, the lvd would be triggered, and the system is reset. the lvd detect level is different by each mcu. the lvd volta ge level is a point of voltage and not easy to cover all dead - band range. using lvd to improve brown out reset is depend on application requirement and environment . if the power variation is very deep, violent and trigger the lvd, the lvd can be the protec tion. if the power variation can touch the lvd detect level and make system work error, the lvd can t be the protection and need to other reset methods. more detail lvd information is in the electrical characteristic section. the lvd is three levels desig n (1.8v/2.4v/3. 3 v) and controlled by lvd code option. the 1.8v lvd is always enable for power on reset and brown out reset. the 2.4v lvd includes lvd reset function and flag function to indicate vdd status function . the 3. 3 v includes flag function to indic ate vdd status. lvd flag function can be an easy low battery detector . lvd24, lvd3 3 flags indicate vdd voltage level. for low battery detect application, only checking lvd24, lvd3 3 status to be battery status. this is a cheap and easy solution. 0 ef h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie lvd24 lvd3 3 - - stkpb2 stkpb1 stkpb0 read/write r/w r r - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit 6 lvd24 : lvd24 low voltage detect indicator. 0 = vdd > lvd24 detect level. 1 = vdd < lvd24 detect level. bit 5 lvd3 3 : lvd3 3 low voltage detect indicator. 0 = vdd > lvd3 3 detect level. 1 = vdd < lvd3 3 detect level. lvd lvd code option lvd_l lvd_m lvd_h 1.8v reset available available available 2.4v flag - available - 2.4v reset - - avail able 3. 3 v flag - - available lvd_l if vdd < 1.8v, system will be reset. disable lvd24 and lvd3 3 bit of pflag register. lvd_m if vdd < 1.8v, system will be reset. enable lvd24 bit of pflag register. if vdd > 2.4v, lvd24 is 0 . if vdd <= 2.4v, lvd24 fla g is 1 . disable lvd3 3 bit of pflag register. lvd_h if vdd < 2.4v, system will be reset. enable lvd24 bit of pflag register. if vdd > 2.4v, lvd24 is 0 . if vdd <= 2.4v, lvd24 flag is 1 . enable lvd3 3 bit of pflag register. if vdd > 3. 3 v, lvd3 3 is 0 . if vdd <= 3. 3 v, lvd3 3 flag is 1 . lvd_max if vdd < 3.3v, system will be reset. ? note: 1. after any lvd reset, lvd24, lvd3 3 flags are cleared. 2. the voltage level of lvd 2.4v or 3. 3 v is for design reference only. don t use the lvd indicator as precision vdd measurement.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 48 version 1. 4 3.4.3 brown out reset improvement how to improve the brown reset condition? there are some methods to improve brown out reset as following. ? lvd reset ? watchdog reset ? reduce the system executing rate ? external reset circuit. (zener diode reset ci rcuit, voltage bias reset circuit, external reset ic) ? note: 1. the zener diode reset circuit , voltage bias reset circuit and external reset ic can completely improve the brown out reset, dc low battery and ac slow power down condition s. 2. for ac power application and enhance eft performance, the system clock is 4mhz/4 (1 mips) and use external reset ( zener diode reset circuit , voltage bias reset circuit , external reset ic ). the structure can improve noise effective and get good eft characteristi c. watchdog reset: the watchdog timer is a protection to make sure the system executes well. normally the watchdog timer would be clear at one point of program. dont clear the watchdog timer in several addresses. the system executes normally and the w atchdog won t reset system. when the system is under dead - band and the execution error, the watchdog timer cant be clear by program. the watchdog is continuously counting until overflow occurrence. the overflow signal of watchdog timer triggers the system to reset, and the system return to normal mode after reset sequence. this method also can improve brown out reset condition and make sure the system to return normal mode. if the system reset by watchdog and the power is still in dead - band, the system re set sequence wont be successful and the system stays in reset status until the power return to normal range. watchdog timer application note is as following. reduce the system executing rate: if the system rate is fast and the dead - band exists, to reduce the system executing rate can improve the dead - band. the lower system rate is with lower minimum operating voltage. select the power voltage that s no dead - band issue and find out the mapping system rate. adjust the system rate to the value and the system exits the dead - band issue. this way needs to modify whole program timing to fit the application requirement. external reset circuit: the external reset methods also can improve brown out reset and is the complete solution. there are three external reset circuits to improve brown out reset including zener diode reset circuit , voltage bias reset circuit and external reset ic . these three reset structures use external reset signal and control to make sure the mcu be reset under power dropping and under dead - band. the external reset information is describe d in the next section.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 49 version 1. 4 3.5 external reset external reset function is controlled by reset_pin code option. set the code option as reset option to enable external reset function. external reset pin is s chmitt trigger structure and low level active. the system is running when reset pin is high level voltage input. the reset pin receives the low voltage and the system is reset. the external reset operation actives in power on and normal running mode. durin g system power - up, the external reset pin must be high level input, or the system keeps in reset status. external reset sequence is as following. ? external reset (only external reset pin enable): system checks external reset pin status. if external reset p in is not high level, the system keeps reset status and waits external reset pin released. ? system initialization: all system registers is set as initial conditions and system is ready. ? oscillator warm up: oscillator operation is successfully and supply to system clock. ? program executing: power on sequence is finished and program executes from org 0. the external reset can reset the system during power on duration, and good external reset circuit can protect the system to avoid working at unusual power c ondition, e.g. brown out reset in ac power application 3.6 external reset circu it 3.6.1 simply rc reset circuit this is the basic reset circuit, and only includes r1 and c1. the rc circuit operation makes a slow rising signal into re set pin as power up. the reset signal is slower than vdd power up timing, and system occurs a power on signal from the timing difference. ? note: the reset circuit is no any protection against unusual power or brown out reset. mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf r2 100 ohm
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 50 version 1. 4 3.6.2 diode & rc reset circui t this is the better reset circuit. the r1 and c1 circuit operation is like the simply reset circuit to make a power on signal. the reset circuit has a simply protection against unusual power. the diode offers a power positive path to conduct higher power to vdd. it is can make reset pin voltage level to synchronize with vdd voltage. the structure can improve slight brown out reset condition. ? note: the r2 100 ohm resistor of simply reset circuit and diode & rc reset circui t is necessary to limit any current flowing into reset pin from external capacitor c in the e vent of reset pin breakdown due to electrostatic discharge (esd) or electrical over - stress (eos). 3.6.3 zener diode reset circuit the ze ner diode reset circuit is a simple low voltage detector and can improve brown out reset condition completely . use zener voltage to be the active level. when vdd voltage level is above vz + 0.7v , the c terminal of the pnp transistor outputs high voltage and mcu operates normally. when vdd is below vz + 0.7v , the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by zener specification . select the right zener voltage to conform the application. mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf diode r2 100 ohm mcu vdd vss vcc gnd r s t r1 33k ohm r3 40k ohm r2 10k ohm vz q1 e c b
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 51 version 1. 4 3.6.4 voltage bias reset circuit the voltage bias reset circuit is a low cost voltage detector and can improve brown out reset condition completely . the operating voltage is not accurate as zener diode reset circuit. use r1, r2 bia s voltage to be the active level. when vdd voltage level is above or equal to 0.7v x (r1 + r2) / r1 , the c terminal of the pnp transistor outputs high voltage and mcu operates normally. when vdd is below 0.7v x (r1 + r2) / r1 , the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by r1, r2 resistances. select the right r1, r2 value to conform the application. in the circuit diagram condition, the mcu s reset pin level varies with vdd voltage variation , and the differential voltage is 0.7v. if the vdd drops and the voltage lower than reset pin detect level, the system would be reset. if want to make the reset active earlier, set the r2 > r1 and the cap between vdd and c terminal voltage is larg er than 0.7v. the external reset circuit is with a stable current through r1 and r2. for power consumption issue application, e.g. dc power system, the current must be consider ed to whole system power consumption. ? note: under unstable power condition as b rown out reset, zener diode rest circuit and voltage bias reset circuit can protects system no any error occurrence as power dropping. when power drops below the reset detect voltage, the system reset would be triggered, and then system executes reset sequence. that makes sure the system work well under unstable power situation. 3.6.5 external reset ic the external reset circuit also use external reset ic to enhance mcu reset performance. this is a high cost and good effect sol ution. by different application and system requirement to select suitable reset ic. the reset circuit can improve all power variation . mcu vdd vss vcc gnd r s t r1 47k ohm r3 2k ohm r2 10k ohm q1 e c b mcu vdd vss vcc gnd r s t reset ic vdd vss rst bypass capacitor 0.1uf
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 52 version 1. 4 4 4 4 system clock 4.1 overview the micro - controller is a dual clock system including high - speed and low - speed clocks. the high - sp eed clock includes internal high - speed oscillator and external oscillators selected by high_clk code option. the low - speed clock is from internal low - speed oscillator controlled by clkmd bit of oscm register. both high - speed clock and low - speed clock c an be system clock source through a divider to decide the system clock rate. ? high - speed oscillator internal high - speed oscillator is 16mhz rc type called ihrc and ihrc_rtc . external high - speed oscillator includes crystal/ ceramic (4mhz, 12mhz, 32khz) and rc type. ? low - speed oscillator internal low - speed oscillator is 16khz rc type called ilrc . ? system clock block diagram ? hosc: high_clk code option. ? fhosc: external high - speed clock / internal high - speed rc clock. ? flos c: internal low - speed rc clock (about 16khz@3v and @5v) . ? fosc: system clock source. ? fcpu: instruction cycle. 4.2 fcpu (instruction cy cle) the system clock rate is instruction cycle called fcpu which is divided from the system clock source and decides the sys tem operating rate. fcpu rate is selected by high_fcpu code option and the range is fhosc/ 1 ~fhosc/1 28 under system normal mode. if the system high clock source is external 4mhz crystal, and the high_fcpu code option is fhosc/4, the fcpu frequency is 4mhz/4 = 1mhz. under system slow mode, the fcpu range is fl osc/ 1~flosc/8 controlled by low_fcpu code option, if low_fcpu code option is flosc/4, the fcpu frequency is 16khz/4=4khz. 4.3 noise filter the noise filter controlled by noise_filter code option is a low pass filter and supports external oscillator including rc and crystal modes. the purpose is to filter high rate noise coupling on high clock signal from external oscillator. in high noisy environment, enable noise_filter code option is the strongly reco mmend ation to reduce noise effect. 4.4 system high - speed clock the system high - speed clock has internal and external two - type. the external high - speed clock includes 4mhz, 12mhz, 32khz crystal/ ceramic and rc type. these high - speed oscillators are selected by high_clk code option. the internal high - speed clock supports real time clock (rtc) function. under ihrc_rtc mode, the internal high - speed clock and external 32khz oscillator active. the internal high - speed clock is the system clock source, and the exter nal 32khz oscillator is the rtc clock source to supply a accurately real time clock rate. f h o s c . f c p u = f h o s c / 1 ~ f h o s c / 1 2 8 f l o s c . f c p u = f l o s c / 1 ~ f l o s c / 8 c p u m [ 1 : 0 ] x i n x o u t s t p h x h o s c h i g h _ f c p u c o d e o p t i o n f o s c f o s c c l k m d f c p u l o w _ f c p u c o d e o p t i o n
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 53 version 1. 4 4.4.1 high_clk code option for difference clock functions, sonix provides multi - type system high clock options controlled by high_clk code option. the high_clk code op tion defines the system oscillator types including ihrc_16m, ihrc_rtc, rc, 32k x tal, 12m x tal and 4m x tal. these oscillator options support different bandwidth oscillator. ? ihrc_ 16 m: the system high - speed clock source is internal high - speed 16mhz rc ty pe oscillator. in the mode, xin and xout pins are bi - direction gpio mode, and not to connect any external oscillator device. ? ihrc_rtc: the system high - speed clock source is internal high - speed 16mhz rc type oscillator. the rtc clock source is external low - speed 32768hz crystal. the xin and xout pins are defined to drive external 32768hz crystal and disables gpio function . ? rc: the system high - speed clock source is external low cost rc type oscillator. the rc oscillator circuit only connects to xin pin, and the xout pin is bi - direction gpio mode. ? 32k x tal: the system high - speed clock source is external low - speed 32768hz crystal. the option only supports 32768hz crystal and the rtc function is workable. ? 12m x tal: the system high - speed clock source is exte rnal high - speed crystal/ceramic. the oscillator bandwidth is 10mhz~16mhz. ? 4m x tal: the system high - speed clock source is external high - speed crystal/resonator. the oscillator bandwidth is 1mhz~10mhz. for power consumption under ihrc_rtc mode, the int ernal high - speed oscillator and internal low C speed oscillator stops and only external 32khz crystal actives under green mode. the condition is the watchdog timer can t be always_on option, or the internal low - speed oscillator actives. 4.4.2 internal high - spe ed oscillator rc type (ihrc) the internal high - speed oscillator is 16mhz rc type. the accuracy is 2% under commercial condition. when the high_clk code option is ihrc_16m or ihrc_rtc , the internal high - speed oscillator is enabled. ? ihrc_16m: the s ystem high - speed clock is internal 16mhz oscillator rc type. xin/xout pins are general purpose i/o pins. ? ihrc_rtc: the system high - speed clock is internal 16mhz oscillator rc type, and the real time clock is external 32768hz crystal. xin/xout pins connect with external 32768hz crystal. 4.4.3 external high - speed oscillator the external high - speed oscillator includes 4mhz, 12mhz, 32khz and rc type. the 4mhz, 12mhz and 32khz oscillators support crystal and ceramic types connected to xin/xout pins with 20pf capacito rs to ground. the rc type is a low cost rc circuit only connected to xin pin. the capacitance is not below 100pf , and use the resistance to decide the frequency. 4.4.4 external oscillator application circuit crystal/ceramic rc type ? note: connect the crystal/ceramic and c as near as possible to the xin/xout/vss pins of micro - controller. connect the r and c as near as possible to the vdd pin of micro - controller. mcu vcc gnd c 20pf xin x o u t vdd v s s c 20pf crystal r mcu vcc gnd xin x o u t v d d vss c
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 54 version 1. 4 4.5 system low - speed clock the syste m low clock source is the internal low - speed oscillator built in the micro - controller. t he low - speed oscillator uses rc type oscillator circuit. the frequency is affected by the voltage and temperature of the system. in common condition, the frequency of t he rc oscillator is about 16khz . the internal low rc supports watchdog clock source and system slow mode controlled by clkmd bit of oscm register. ? flosc = internal low rc oscillator (about 16kh z ) . ? slow mode fcpu = flosc/ 1 ~ flosc/8 controlled by low_ fcpu code option. when watchdog timer is disabled and system is in power down mode, the internal low rc stops. ? example: stop internal low - speed oscillator by power down mode as watchdog timer disable b0bset fcpum0 ; to stop external high - speed oscill ator and internal low - speed ; oscillator called power down mode (sleep mode). 4.6 oscm register the oscm register is a n oscillator control register. it control s oscillator status, system mode. 095h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 oscm 0 0 0 cpum1 cpum0 clkmd stphx 0 read/write - - - r/w r/w r/w r/w - after reset - - - 0 0 0 0 - bit 1 stphx: e xternal high - speed oscillator control bit. 0 = external high - speed oscillator f ree run . 1 = external high - speed oscillator f ree run s top. i n ternal low - speed rc oscillator is still running. bit 2 clkmd: system high/low clock mode control bit. 0 = n ormal (dual) mode . system clock is high clock. 1 = s low mode. system clock is internal low clock. bit[4:3] cpum [1:0] : cpu operating mode contro l bit s . 00 = normal . 01 = sleep (power down) mode . 10 = green mode . 11 = reserved. stphx bit controls internal high speed rc type oscillator and external oscillator operations. when stphx=0 , the external oscillator or internal high speed rc type osci llator active. when stphx=1 , the external oscillator or internal high speed rc type oscillator are disabled. the stphx function is depend on different high clock options to do different controls. ? ihrc_ 16 m: stphx=1 disables internal high speed rc type oscillator. ? ihrc_rtc: stphx=1 disables internal high speed rc type oscillator , and external 32768hz crystal keeps oscillating . ? rc, 4m, 12m, 32k: stphx=1 disables external oscillator.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 55 version 1. 4 4.7 system clock measurement under design period, the users can m easure system clock speed by software instruction cycle (fcpu). this way is useful in rc mode. ? example: fcpu instruction cycle of external oscillator . b0bset p0m.0 ; set p0.0 to be output mode for outputting fcpu toggle signal. @@: b0bset p 0.0 ; o utput fcpu toggle signal in low - speed clock mode. b0bclr p0.0 ; measure the fcpu frequency by oscilloscope . jmp @b ? note: do not measure the rc frequency directly from xin; the probe impendence will affect the rc frequency. 4.8 system cloc k timing parameter symbol description typical hardware configuration time tcfg 2048*f ilrc 128ms @ f ilrc = 16khz oscillator start up time tost the start - up time is depended on oscillators material, factory and architecture. normally, the low - speed oscil lators start - up time is lower than high - speed oscillator. the rc type oscillators start - up time is faster than crystal type oscillator. - oscillator warm - up time tosp oscillator warm - up time of reset condition . 2048*f hosc (power on reset, lvd reset, watchdog reset, external reset pin active.) 64ms @ f hosc = 32khz 512us @ f hosc = 4mhz 128 us @ f hosc = 16 mhz oscillator warm - up time of power down mode wake - up condition . 2048*f hosc crystal/resonator type oscillator, e.g. 32768hz crystal, 4mhz crysta l, 16mhz crystal 32 *f hosc rc type oscillator , e.g. external rc type oscillator, internal high - speed rc type oscillator. x tal: 64ms @ f hosc = 32khz 512us @ f hosc = 4mhz 128 us @ f hosc = 16 mhz rc: 8u s @ f hosc = 4m hz 2u s @ f hosc = 16m hz ? power on reset ti ming ? external reset pin reset timing v d d p o w e r o n r e s e t f l a g o s c i l l a t o r f c p u ( i n s t r u c t i o n c y c l e ) t c f g t o s t t o s p v p
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 56 version 1. 4 ? watchdog reset timing ? power down mode wake - up timing ? green mode wake - up timing e x t e r n a l r e s e t p i n o s c i l l a t o r f c p u ( i n s t r u c t i o n c y c l e ) t c f g t o s t t o s p r e s e t p i n f a l l i n g e d g e t r i g g e r s y s t e m r e s e t . r e s e t p i n r e t u r n s t o h i g h s t a t u s . s y s t e m i s u n d e r r e s e t s t a t u s . e x t e r n a l r e s e t f l a g w a t c h d o g r e s e t f l a g o s c i l l a t o r f c p u ( i n s t r u c t i o n c y c l e ) t c f g t o s t t o s p w a t c h d o g t i m e r o v e r f l o w . w a k e - u p p i n r i s i n g e d g e o s c i l l a t o r f c p u ( i n s t r u c t i o n c y c l e ) t o s p t o s t w a k e - u p p i n f a l l i n g e d g e s y s t e m i n s e r t s i n t o p o w e r d o w n m o d e . e d g e t r i g g e r s y s t e m w a k e - u p . w a k e - u p p i n r i s i n g e d g e o s c i l l a t o r f c p u ( i n s t r u c t i o n c y c l e ) w a k e - u p p i n f a l l i n g e d g e s y s t e m i n s e r t s i n t o g r e e n m o d e . e d g e t r i g g e r s y s t e m w a k e - u p . 0 x 0 0 0 x f f 0 x f e 0 x 0 1 0 x 0 2 . . . 0 x f d . . . . . . . . . . . . . . . t i m e r t i m e r o v e r f l o w .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 57 version 1. 4 ? oscillator start - up time the start - up time is depended on oscillators material, factory and architecture. normally, the low - speed oscillators start - up time is lower than high - speed oscillator. the rc type oscillators start - up time is faster than crystal type oscillator. l o w s p e e d c r y s t a l ( 3 2 k , 4 5 5 k ) t o s t c r y s t a l t o s t r c o s c i l l a t o r t o s t c e r a m i c / r e s o n a t o r t o s t
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 58 version 1. 4 5 5 5 system operation mode 5.1 overview the chip builds in four operating mode for difference clock rate and power saving reason. these modes control oscillators, op - code operation and analog peripheral devices operation. ? normal mode: system high - speed operating mode. ? slow mode: system low - speed operating mode. ? p ower down mode : sys tem power saving mode (sleep mode). ? green mode : system ideal mode. operating mode control block p o w e r d o w n m o d e s l o w m o d e c l k m d = 1 c l k m d = 0 c p u m 1 , c p u m 0 = 0 1 . w a k e - u p c o n d i t i o n : p 0 , p 1 i n p u t s t a t u s i s l e v e l c h a n g i n g . t 0 t i m e r c o u n t e r i s o v e r f l o w . c p u m 1 , c p u m 0 = 1 0 . n o r m a l m o d e g r e e n m o d e w a k e - u p c o n d i t i o n : p 0 , p 1 i n p u t s t a t u s i s l e v e l c h a n g i n g . t 0 t i m e r c o u n t e r i s o v e r f l o w . w a k e - u p c o n d i t i o n : p 0 , p 1 i n p u t s t a t u s i s l e v e l c h a n g i n g . m s p m a t c h e d d e v i c e a d d r e s s . r e s e t c o n t r o l b l o c k o n e o f r e s e t t r i g g e r s o u r c e s a c t i v e s . o n e o f r e s e t t r i g g e r s o u r c e s a c t i v e s . o n e o f r e s e t t r i g g e r s o u r c e s a c t i v e s .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 59 version 1. 4 operating mode clock control table operating mode normal mode slow mode green mode power down mode ihrc ihrc, ihrc_rtc: runn ing ext. osc: disable ihrc, ihrc_rtc: by stphx ext. osc: disable ihrc, ihrc_rtc: by stphx ext. osc: disable stop ilrc running running running stop ext. osc. ihrc: disable ihrc_rtc, ext. osc: running ihrc: disable ihrc_rtc: running ext. osc: by stphx ihrc : by stphx ihrc_rtc: running ext. osc: by stphx stop cpu instruction executing executing stop stop t0 timer active by t0enb active by t0enb active by t0enb inactive tc0 timer (timer, event counter, pwm) active by tc0enb active by tc0enb active by tc0enb inactive tc1 timer (timer, event counter, pwm) active by tc1enb active by tc1enb active by tc1enb inactive tc2 timer (timer, event counter, pwm) active by tc2enb active by tc2enb active by tc2enb inactive t1 timer (timer, event counter) active by t1enb active by t1enb active by t1enb inactive sio active as enable inactive inactive inactive msp active as enable inactive inactive inactive uart active as enable inactive inactive inactive adc active as enable active as enable active as enable inactive watchdog timer by watch_dog code option by watch_dog code option by watch_dog code option by watch_dog code option internal interrupt all active all active all active all inactive external interrupt all active all active all active all inactive wakeup s ource - - p0, p1, t0, reset p0, p1, msp, reset ? ext.osc: external high - speed oscillator (xin/xout). ? i h rc: internal high - speed oscillator rc type. ? ilrc: internal low - speed oscillator rc type. ? note: 1. sio, msp and uart inactive in slow mode and green mo de, because the clock source doesnt exist. use firmware to disable sio, msp, uart function before inserting slow mode and green mode. 2. in ihrc_rtc mode, stphx only controls ihrc, not ext. 32k. stphx=0, ihrc actives. stphx=1, ihrc stops. 5.2 normal mode the normal mode is system high clock operating mode. the system clock source is from high speed oscillator. the program is executed. after power on and any reset trigger released, the system inserts into normal mode to execute program. when the system is wake - up from power down mode, the system also inserts into normal mode. in normal mode, the high speed oscillator actives, and the power consumption is largest of all operating modes. ? the program is executed, and full functions are controllable . ? the system rate is high speed. ? the high speed oscillator and internal low speed rc type oscillator active. ? normal mode can be switched to other operating modes through oscm register. ? power down mode is wake - up to normal mode. ? slow mode is switched to normal mode. ? green mode from normal mode is wake - up to normal mode.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 60 version 1. 4 5.3 slow mode the slow mode is system low clock operating mode. the system clock source is from internal low speed rc type oscillator. the slow mode is controlled by clkmd bit of oscm register. when c lkmd=0, the system is in normal mode. when clkmd=1, the system inserts into slow mode. the high speed oscillator wont be disabled automatically after switching to slow mode, and must be disabled by spthx bit to reduce power consumption. in slow mode, the system rates are flosc/1, flosc/2, flosc/4, flosc/8 (flosc is internal low speed rc type oscillator frequency) controlled by code option. ? the program is executed, and full functions are controllable . ? the system rate is low speed (flosc/1, flosc/2, flosc /4, flosc/8 controlled by code option). ? the internal low speed rc type oscillator actives, and the high speed oscillator is controlled by stphx=1. in slow mode, to stop high speed oscillator is strongly recommendation . ? slow mode can be switched to other operating modes through oscm register. ? power down mode from slow mode is wake - up to normal mode. ? normal mode is switched to slow mode. ? green mode from slow mode is wake - up to slow mode. ? 5.4 power down mdoe the power down mode is the system ideal status. n o program execution and oscillator operation. only internal regulator actives to keep all control gates status, register status and sram contents. the power down mode is waked up by p0, p1 hardware level change trigger. p0 wake - up function is always enable s, and p1 wake - up function is controlled by p1w register. any operating modes into power down mode, the system is waked up to normal mode. inserting power down mode is controlled by cpum0 bit of oscm register. when cpum0=1, the system inserts into power do wn mode. after system wake - up from power down mode, the cpum0 bit is disabled (zero status) automatically, and the wake bit set as 1. ? the program stops executing, and full functions are disabled. ? all oscillators including external high speed oscillat or, internal high speed oscillator and internal low speed oscillator stop. ? the system inserts into normal mode after wake - up from power down mode. ? t h e power down mode wake - up source is p0 and p1 level change trigger. ? after system wake - up from power down mode, the wake bit set as 1 and cleared by program. ? if wake - up source is external interrupt source, the wake bit wont be set, and external interrupt irq bit is set. the system issues external interrupt request and executes interrupt service routine. ? note: if the system is in normal mode, to set stphx=1 to disable the high clock oscillator. the system is under no system clock condition. this condition makes the system stay as power down mode, and can be wake - up by p0, p1 level change trigger.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 61 version 1. 4 5.5 gr een mode the green mode is another system ideal status not like power down mode. in power down mode, all functions and hardware devices are disabled. but in green mode, the system clock source keeps running, so the power consumption of green mode is larger than power down mode. in green mode, the program isnt executed, but the timer with wake - up function actives as enabled, and the timer clock source is the non - stop system clock. the green mode has 2 wake - up sources. one is the p0, p1 level change trigger wake - up. the other one is internal timer with wake - up function occurring overflow. thats mean users can setup one fix period to timer, and the system is waked up until the time out. inserting green mode is controlled by cpum1 bit of oscm register. when cp um1=1, the system inserts into green mode. after system wake - up from green mode, the cpum1 bit is disabled (zero status) automatically, and the wake bit set as 1. ? the program stops executing, and full functions are disabled. ? only the timer with wake - u p function actives. ? the oscillator to be the system clock source keeps running, and the other oscillators operation is depend on system operation mode configuration. ? if inserting green mode from normal mode, the system insets to normal mode after wake - up . ? if inserting green mode from slow mode, the system insets to slow mode after wake - up. ? the green mode wake - up sources are p0, p1 level change trigger and unique time overflow. ? after system wake - up from power down mode, the wake bit set as 1 and clear ed by program. ? if wake - up source is external interrupt source, the wake bit wont be set, and external interrupt irq bit is set. the system issues external interrupt request and executes interrupt service routine. ? if the function clock source is system clo ck, the functions are workable as enabled and under green mode, e.g. timer, pwm, event counterbut the functions doesnt has wake - up function. ? note: sonix provides greenmode macro to control green mode operation. it is necessary to use greenmode macr o to control system inserting green mode. the macro includes three instructions. please take care the macro length as using branch type instructions , e.g. bts0, bts1, b0bts0, b0bts1, ins, incms, decs, decms, cmprs, jmp, or the routine would be error.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 62 version 1. 4 5.6 operating mode contr ol macro sonix provides operating mode control macros to switch system operating mode easily. macro length description sleepmode 1 - word the system insets into sleep mode (power down mode). greenmode 3 - word the system inserts into green mode. slowmode 2 - word the system inserts into slow mode and stops high speed oscillator. slow2normal 5 - word the system returns to normal mode from slow mode. the macro includes operating mode switch, enable high speed oscillator, high speed osci llator warm - up delay time. ? example: switch normal/slow mode to power down (sleep) mode. sleepmode ; declare ? example: switch normal mode to slow mode. slowmode ; declare ? example: switch slow mode to normal mode (t he external high - speed oscillator stops ). slow2normal ; declare slow2normal macro directly. ? example: switch normal/slow mode to green mode. greenmode ; declare ? example: switch norm al/slow mode to green mode and enable t0 wake - up function . ; set t0 timer wakeup function . b0bclr ft0ien ; to disable t0 interrupt service b0bclr ft0enb ; to disable t0 timer mov a,#20h ; b0mov t0m,a ; to set t0 clock = fcpu / 64 mov a,#74h b 0mov t0c,a ; to set t0c initial value = 74h (to set t0 interval = 10 ms) b0bclr ft0ien ; to disable t0 interrupt service b0bclr ft0irq ; to clear t0 interrupt request b0bset ft0enb ; to enable t0 timer ; go into green mode greenmode ; declar e ? example: switch normal/slow mode to green mode and enable t0 wake - up function with rtc . clr t0c ; clear t0 counter. b0bset ft0 tb ; enable t0 rtc function. b0bset ft0enb ; to enable t0 timer . ; go into green mode greenmode ; declare
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 63 version 1. 4 5.7 wakeup 5.7.1 overview under power down mode (sleep mode) or green mode , program doesn t execute. the wakeup trigger can wake the system up to normal mode or slow mode. the wakeup trigger sources are external trigger (p0/p1 level change) and internal trigger (t0 timer overflow). the wakeup function builds in interrupt operation issued irq flag and trigger system executing interrupt service routine as system wakeup occurrence . ? power down mode is w aked up to normal mode. the wakeup trigger is only external trigger (p0/p1 level change) ? green mode is waked up to last mode (normal mode or slow mode). the wakeup triggers are external trigger (p0/p1 level change) and internal trigger (t0 timer overflow). ? wakeup interrupt function issues wakeirq as system wakeup from power down mode or green mode. if wakeien is 1 meaning enable, the wakeup event triggers program counter point to interrupt vector (org 8) executing interrupt service routine. ? note: if w ake - up source is external interrupt source, the wake bit wont be set, and external interrupt irq bit is set. the system issues external interrupt request and executes interrupt service routine. 5.7.2 wakeup time when the system is in power down mode (sleep mode), the high clock oscillator stops. when waked up from power down mode, mcu waits for 2048 external high - speed oscillator clocks and 32 internal high - speed oscillator clocks as the wakeup time to stable the oscillator circuit. after the wakeup time, th e system goes into the normal mode. ? note : wakeup from green mode is no wakeup time because the clock doesnt stop in green mode. the value of the external high clock oscillator wakeup time is as the following. the wakeup time = 1/fosc * 2048 (sec) + high clock start - up time example: in power down mode (sleep mode), the system is waked up. after the wakeup time, the system goes into normal mode. the wakeup time is as the following. the wakeup time = 1/fosc * 2048 = 0.512 ms (fosc = 4 mhz ) the tota l wakeup time = 0.512 ms + oscillator start - up time the value of the internal high clock oscillator rc type wakeup time is as the following. the wakeup time = 1/fosc * 32 (sec) + high clock start - up time example: in power down mode (sleep mode), the s ystem is waked up. after the wakeup time, the system goes into normal mode. the wakeup time is as the following. the wakeup time = 1/fosc * 32 = 2 u s (fhosc = 16 mhz ) ? note : the high clock start - up time is depended on the vdd and oscillator type of high clock.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice an d isp sonix technology co., ltd page 64 version 1. 4 5.7.3 p1w wakeup control register under power down mode (sleep mode) and green mode, the i/o ports with wakeup function are able to wake the system up to normal mode. the wake - up trigger edge is level changing. when wake - up pin occurs rising edge o r falling edge, the system is waked up by the trigger edge. the port 0 and port 1 have wakeup function. port 0 wakeup function always enables, but the port 1 is controlled by the p1w register. 0 9e h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1w p17 w p16w p15w p14w p13w p12w p11w p10w read/write r/ w r/ w r/ w r/ w r/ w r/ w r/ w r/ w after reset 0 0 0 0 0 0 0 0 bit[7:0] p10w~p17w: port 1 wakeup function control bits. 0 = disable p1n wakeup function. 1 = enable p1n wakeup function.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 65 version 1. 4 6 6 6 interrupt 6.1 overview th is mcu provides 13 interrupt sources, including 2 external interrupt (int0 /int1 ) and 11 internal interrupt ( t0/t1/ tc 0/tc1/tc2/sio/msp/utx/urx/wake/adc ). the external interrupt can wakeup the chip while the system is switched from power down mode to high - speed normal mode , and interrupt request is latched until return to normal mode . once interrupt service is executed, the gie bit in stkp register will clear to 0 for stopping other interrupt request. on the contrast, when interrupt service exits, the gi e bit will set to 1 to accept the next interrupts request. t he interrupt request signals are stored in intrq register . ? note : the gie bit must enable during all interrupt operation. 6.2 interrupt operation interrupt operati on is controlled by irq and ien bits. the irq is interrupt source event indicator, no matter what interrupt function status (enable or disable). the ien control the system interrupt execution. if ien = 0, the system wont jump to interrupt vector to execut e interrupt routine. if ien = 1, the system executes interrupt operation when each of interrupt irq flags actives. ? ien = 1 and irq = 1, the program counter points to interrupt vector and execute interrupt service routine. when any interrupt requests occ urs, the system provides to jump to interrupt vector and execute interrupt routine. the first procedure is push operation. the end procedure after interrupt service routine execution is pop operation. the push and pop operations arent through ins truction (push, pop) and executed by hardware automatically. ? push operation: push operation saves the contents of acc and working registers (0x80~0x8f) into hardware buffers. push operation executes before program counter points to interrupt vector. th e ram bank keeps the status of main routine and doesnt switch to bank 0 automatically. the ram bank is selected by program. ? pop operation: pop operation reloads the contents of acc and working registers (0x80~0x8f) from hardware buffers. pop operation executes as reti instruction executed. the ram bank switches to last status of main routine after reloading rbank content. ? 0x80~0x87 working registers include l, h, r, z, y, x, pflag, rbank, w0~w7. i n t e n i n t e r r u p t e n a b l e r e g i s t e r i n t e r r u p t e n a b l e g a t i n g i n t r q 1 3 - b i t l a t c h s p 0 0 i r q p 0 1 i r q t 0 i r q i n t e r r u p t v e c t o r a d d r e s s ( 0 0 0 8 h ~ 0 0 1 4 h ) g l o b a l i n t e r r u p t r e q u e s t s i g n a l i n t 0 t r i g g e r t 1 t i m e o u t t c 1 t i m e o u t t c 2 t i m e o u t t 1 i r q i n t 1 t r i g g e r t 0 t i m e o u t s i o t r a n s m i t t e r e n d u a r t t r a n s m i t e n d u a r t r e c e i v e e n d t c 1 i r q t c 2 i r q s i o i r q u t x i r q u r x i r q t c 0 t i m e o u t t c 0 i r q m s p w a k e m s p i r q w a k e i r q a d c c o n v e r t i n g e n d a d c i r q
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 66 version 1. 4 6.3 inten interrupt enab le register inten is the interrup t request control register including eleven internal interrupts, two external interrupts enable control bits. one of the register to be set 1 is to enable the interrupt request function. once of the interrupt occur, the stack i s incremented and program j ump to org 8 ~14 to execute interrupt service routines. the program exits the interrupt service routine when the returning interrupt service routine instruction (reti) is executed. 09ah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 inten 0 adcien t 1 ien tc 2 ien tc 1 ien tc 0 ien t 0 ien p01ien p00ien read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 0 p00ien: external p0.0 interrupt (int0) control bit. 0 = d isable int0 interrupt function . 1 = en able int0 interrupt function . bit 1 p 0 1 ien: external p0. 1 interrupt (int1) control bit. 0 = d isable int1 interrupt function . 1 = en able int1 interrupt function . bit 2 t0 ien: t0 timer interrupt control bit. 0 = d isable t0 interrupt function . 1 = en able t0 interrupt function . bit 3 tc0 ien: tc 0 timer interrupt control bit. 0 = d isable tc0 interrupt function . 1 = en able tc0 interrupt function . bit 4 tc1 ien: tc1 timer interrupt control bit. 0 = d isable tc1 interrupt function . 1 = en able tc1 interrupt function . bit 5 t c2 ien: tc2 t imer interrupt control bit. 0 = d isable tc2 interrupt function . 1 = en able tc2 interrupt function . bit 6 t 1 ien: t1 t imer interrupt control bit. 0 = d isable t1 interrupt function . 1 = en able t1 interrupt function . bit 7 adc ien: adc interrupt control bit. 0 = d isable adc interrupt function . 1 = en able adc interrupt function . 09bh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 inten 1 - - - msp ien utx ien urx ien sio ien wake ien read/write - - - r/w r/w r/w r/w r/w after reset - - - 0 0 0 0 0 bit 0 wake ien: wakeup inte rrupt control bit. 0 = d isable wakeup interrupt function . 1 = en able wakeup interrupt function . bit 1 sio ien: sio interrupt control bit. 0 = d isable sio interrupt function . 1 = en able sio interrupt function . bit 2 urx ien: uart receive interrupt control b it. 0 = d isable uart receive interrupt function . 1 = en able uart receive interrupt function . bit 3 utx ien: uart transmit interrupt control bit. 0 = d isable uart transmit interrupt function . 1 = en able uart transmit interrupt function . bit 4 msp ien: msp i nterrupt control bit. 0 = d isable msp interrupt function . 1 = en able msp interrupt function .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 67 version 1. 4 6.4 intrq interrupt requ est register intrq is the interrupt request flag register. the register includes all interrupt request indication flags. each one of the inte rrupt request s occurs, the bit of the intrq register would be set 1. the intrq value needs to be clear by programming after detecting the flag. in the interrupt vector of program, users know the any interrupt requests occurring by the register and do the routine corresponding of the interrupt request. 097h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 intrq 0 adcirq t 1 irq tc 2 irq t c1 irq t c0 irq t0 irq p01irq p00irq read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 0 p00i rq : external p0.0 interrupt (int0) request flag . 0 = non e int0 interrupt request . 1 = int0 interrupt request . bit 1 p0 1 i rq : external p0. 1 interrupt (int1) request flag . 0 = non e int1 interrupt request . 1 = int1 interrupt request . bit 2 t 0 i rq : t0 timer interr upt request flag . 0 = non e t0 interrupt request . 1 = t0 interrupt request . bit 3 tc0 i rq : tc0 timer interrupt request flag . 0 = non e tc0 interrupt request . 1 = tc0 interrupt request . bit 4 tc1 i rq : tc1 timer interrupt request flag . 0 = non e tc1 interrupt r equest . 1 = tc1 interrupt request . bit 5 t c2 i rq : tc2 t imer interrupt request flag. 0 = non e tc2 interrupt request . 1 = tc2 interrupt request . bit 6 t 1 i rq : t1 t imer interrupt request flag. 0 = non e t1 interrupt request . 1 = t1 interrupt request . bit 7 ad c i rq : adc interrupt request flag. 0 = non e adc interrupt request . 1 = adc interrupt request . 098h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 intrq 1 msp irq utx irq urx irq sio irq wake irq read/write r/w r/w r/w r/w r/w after reset 0 0 0 0 0 bit 0 wake i rq : wakeup interrupt request flag . 0 = non e wakeup interrupt request . 1 = wakeup interrupt request . bit 1 sio i rq : sio interrupt request flag . 0 = non e sio interrupt request . 1 = sio interrupt request . bit 2 urx i rq : uart receive interrupt req uest flag . 0 = non e uart receive interrupt request . 1 = uart receive interrupt request . bit 3 utx i rq : uart transmit interrupt request flag . 0 = non e uart transmit interrupt request . 1 = uart transmit interrupt request . bit 4 msp i rq : msp interrupt request flag . 0 = non e msp interrupt request . 1 = msp interrupt request .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 68 version 1. 4 6.5 gie global interrupt operation gie is the global interrupt control bit. all interrupts start work after the gie = 1 it is necessary for interrupt service request. one of the interrupt req uests occurs, and the program counter (pc) points to the interrupt vector (org 8 ~14 ) and the stack add 1 level. 0 e fh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie lvd24 lvd3 3 - - stkpb2 stkpb1 stkpb0 read/write r/w r r - - r/w r/w r/w after reset 0 - - 1 1 1 bit 7 gie: global interrupt control bit. 0 = disable global interrupt. 1 = enable global interrupt. ? example: set global interrupt control bit (gie). b0bset fgie ; enable gie ? note: the gie bit must enable during all interr upt operation.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 69 vers ion 1. 4 6.6 external interrupt o peration (int0~int1) sonix provides 2 sets external interrupt source s in the micro - controller. int0 and int1 are external interrupt trigger sources and build in edge trigger configuration function. when the external edge trigger occurs, the external interrupt request flag will be set to 1 when the external interrupt control bit enabled. if the external interrupt control bit is disabled, the external interrupt request flag won t active when external edge trigger occu rrence. when external interrupt control bit is enabled and external interrupt edge trigger is occurring, the program counter will jump to the interrupt vector (org 0x0009, 0x000a) and execute interrupt service routine. the external interrupt builds in wak e - up latch function. that means when the system is triggered wake - up from power down mode , the wake - up source is external interrupt source (p0.0 or p0.1), and the trigger edge direction matches interrupt edge configuration, the trigger edge will be latched , and the system executes interrupt service routine fist after wake - up. 0 9 fh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pedge - - - - p01g1 p01g0 p00g1 p00g0 read/write - - - - r/w r/w r/w r/w after reset - - - - 1 0 1 0 bit[ 3 : 2 ] p0 1 g[1:0]: int 1 edge trigger select bits. 00 = reserved, 01 = ris ing edge, 10 = falling edge, 11 = rising/falling bi - direction. bit[ 1 : 0 ] p0 0 g[1:0]: int0 edge trigger select bits. 00 = reserved, 01 = ris ing edge, 10 = falling edge, 11 = rising/falling bi - direction. exa mple: setup int0 interrupt request and bi - direction edge trigger. mov a, #03h b0mov pedge, a ; set int0 interrupt trigger as bi - direction edge. b0bset fp00ien ; e nable int0 interrupt service b0bclr f p00 irq ; c lear int0 interrupt request flag b0bset fgie ; enable gie example: int0 interrupt service routine. org 9 ; interrupt vector jmp int_service int_service: ; push routine to save acc and pflag to buffers. b0bts1 fp00irq ; check p00irq jmp exit_int ; p00irq = 0, exi t interrupt vector b0bclr fp00irq ; reset p00irq exit_int: ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 70 vers ion 1. 4 6.7 t0 interrupt operati on when the t0c counter occurs overflo w, the t0irq will be set to 1 however the t0ien is enable or disable. if the t0ien = 1, the trigger event will make the t0irq to be 1 and the system enter interrupt vector. if the t0ien = 0, the trigger event will make the t0irq to be 1 but the syste m will not enter interrupt vector. users need to care for the operation under multi - interrupt situation. ? example: t0 interrupt request setup. b0bclr ft 0 ien ; d isable t 0 interrupt service b0bclr ft 0 enb ; d isable t 0 timer mov a, #20h ; b0mov t 0 m, a ; s et t 0 clock = f cpu / 64 mov a, #74h ; s et t 0 c initial value = 74h b0mov t 0 c, a ; s et t 0 interval = 10 ms b0bset ft 0 ien ; e nable t 0 interrupt service b0bclr ft 0 irq ; c lear t 0 interrupt request flag b0bset ft 0 enb ; e nable t 0 timer b 0bset fgie ; enable gie example: t0 interrupt service routine. org 0bh ; interrupt vector jmp int_service int_service: b0bts1 ft0irq ; check t0irq jmp exit_int ; t0irq = 0, e xit interrupt vector b0bclr ft0irq ; reset t0irq mov a, #74h b0mov t0c, a ; reset t0c. ; t0 interrupt service routine ? n ote: in rtc mode, dont reset t0c in interrupt service routine.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 71 vers ion 1. 4 6.8 tc0 interrupt operat ion when the tc0c counter overflows, the tc0irq will be set to 1 no matter the tc0ien is enable or disable. if the tc0ien and the trigger event tc0irq is set to b e 1. as the result, the system will execute the interrupt vector. if the tc0ien = 0, the trigger event tc0irq is still set to be 1. moreover, the system wont execute interrupt vector even when the tc0ien is set to be 1. users need to be cautious w ith the operation under multi - interrupt situation. ? example: tc0 interrupt request setup. b0bclr ftc0ien ; disable tc0 interrupt service b0bclr ftc0enb ; disable tc0 timer mov a, # 1 0h ; b0mov tc0m, a ; set tc0 clock = fcpu / 64 mov a, #74h ; set tc0c initial value = 74h b0mov tc0c, a ; set tc0 interval = 10 ms b0bset ftc0ien ; enable tc0 interrupt service b0bclr ftc0irq ; clear tc0 interrupt request flag b0bset ftc0enb ; enable tc0 timer b0bset fgie ; enable gie ? example: t c0 interrupt service routine. org 0ch ; interrupt vector jmp int_service int_service: b0bts1 ftc0irq ; check tc0irq jmp exit_int ; tc0irq = 0, exit interrupt vector b0bclr ftc0irq ; reset tc0irq mov a, #74h b0mov tc0c, a ; reset tc0c. ; tc0 interrupt service routine
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 72 vers ion 1. 4 6.9 tc1 interrupt operat ion when the tc 1c counter overflows, the tc1irq will be set to 1 no matter the tc1ien is enable or disable. if the tc1ien and the trigger event tc1irq is set to be 1. as the result, the system will execute the interrupt vector. if the tc1ien = 0, the trigger event t c1irq is still set to be 1. moreover, the system wont execute interrupt vector even when the tc1ien is set to be 1. users need to be cautious with the operation under multi - interrupt situation. example: tc1 interrupt request setup. b0bclr ftc1ien ; disable tc1 interrupt service b0bclr ftc1enb ; disable tc1 timer mov a, # 1 0h ; b0mov tc1m, a ; set tc1 clock = fcpu / 64 mov a, #74h ; set tc1c initial value = 74h b0mov tc1c, a ; set tc1 interval = 10 ms b0bset ftc1ien ; enable tc1 int errupt service b0bclr ftc1irq ; clear tc1 interrupt request flag b0bset ftc1enb ; enable tc1 timer b0bset fgie ; enable gie example: tc1 interrupt service routine. org 0dh ; interrupt vector jmp int_service int_service: b0bts1 ftc1irq ; check tc1irq jmp exit_int ; tc1irq = 0, exit interrupt vector b0bclr ftc1irq ; reset tc1irq mov a, #74h b0mov tc1c, a ; reset tc1c. ; tc1 interrupt service routine
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 73 vers ion 1. 4 6.10 tc 2 interrupt operation when the tc 2 c counter overflows, the tc 2 irq will be set to 1 no matter the tc 2 ien is enable or disable. if the tc 2 ie n and the trigger event tc 2 irq is set to be 1. as the result, the system will execute the interrupt vector. if the tc 2 ien = 0, the trigger event tc 2 irq is still set to be 1. moreover, the system wont execute interrupt vector even when the tc 2 ien is set to be 1. users need to be cautious with the operation under multi - interrupt situation. example: tc 2 interrupt request setup. b0bclr ftc 2 ien ; disable tc 2 interrupt service b0bclr ftc 2 enb ; disable tc 2 timer mov a, # 1 0h ; b0mov tc 2 m, a ; set tc 2 clock = fcpu / 64 mov a, #74h ; set tc 2 c initial value = 74h b0mov tc 2 c, a ; set tc 2 interval = 10 ms b0bset ftc 2 ien ; enable tc 2 interrupt service b0bclr ftc 2 irq ; clear tc 2 interrupt request flag b0bset ftc 2 enb ; enable tc 2 timer b0bset fgie ; enable gie example: tc 2 interrupt service routine. org 0eh ; interrupt vector jmp int_service int_service: b0bts1 ftc 2 irq ; check tc 2 irq jmp exit_int ; tc 2 ir q = 0, exit interrupt vector b0bclr ftc 2 irq ; reset tc 2 irq mov a, #74h b0mov tc 2 c, a ; reset tc 2 c. ; tc 2 interrupt service routine
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 74 vers ion 1. 4 6.11 t1 interrupt operati on when the t 1 c (t1ch, t1cl) counter occurs overflow, the t 1 irq will be set to 1 however the t 1 ien is enable or disable. if the t 1 ien = 1, th e trigger event will make the t 1 irq to be 1 and the system e nter interrupt vector. i f the t 1 ien = 0, th e trigger event will make the t 1 irq to be 1 but the system will not enter interrupt vector. users need to care for the operation under multi - interrupt situation. ? example: t1 interrupt request setup. b0bclr ft1ien ; d isable t1 inter rupt service b0bclr ft1enb ; d isable t1 timer mov a, #20h ; b0mov t1m, a ; s et t1 clock = f cpu / 32 and falling edge trigger. clr t1ch clr t1cl b0bset ft1ien ; e nable t1 interrupt service b0bclr ft1irq ; c lear t1 interrupt request flag b0bset ft1enb ; e nable t1 timer b0bset fgie ; enable gie example: t1 interrupt service routine. org 0fh ; interrupt vector jmp int_service int_service: b0bts1 ft1irq ; check t1irq jmp exit_int ; t1irq = 0, exit in terrupt vector b0bclr ft1irq ; reset t1irq b0mov a, t1ch b0mov t1chbuf, a b0mov a, t1cl b0mov t1clbuf, a ; save pulse width. clr t1ch clr t1cl ; t1 interrupt service routine
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 75 vers ion 1. 4 6.12 adc interrupt operat ion when the adc converting successfully, the adcirq will be set to 1 no matter the adcien is enable or disable. if the adcien and the trigger event adcirq is set to be 1 . as the result, the system will execute the inte rrupt vector. if the adcien = 0, the trigger event adcirq is still set to be 1 . moreover, the system won t execute interrupt vector even when the adcien is set to be 1 . users need to be cautious with the operation under multi - interrupt situation. ? exa mple: adc interrupt request setup. b0bclr f adc ien ; d isable adc interrupt service mov a, # 10110000b ; b0mov adm , a ; enable p4.0 adc input and adc function. mov a, # 00000000b ; s et adc converting rate = fcpu/16 b0mov adr , a b0bset f a dc ien ; e nable adc interrupt service b0bclr f adc irq ; c lear adc interrupt request flag b0bset fgie ; enable gie b0bset f ads ; start adc transformation ? example: adc interrupt service routine. org 10h ; interrupt vector jmp int_servi ce int_service: b0bts1 fadcirq ; check adcirq jmp exit_int ; adcirq = 0, exit interrupt vector b0bclr fadcirq ; reset adcirq ; adc interrupt service routine
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 76 vers ion 1. 4 6.13 sio interrupt operat ion when the sio converting successfully, the sioirq will be set to 1 no matter the sioien is enable or disable. if the sioien and t he trigger event sioirq is set to be 1 . as the result, the system will execute the interrupt vector. if the sioien = 0, the trigger event sioirq is still set to be 1 . moreover, the system won t execute interrupt vector even when the sioien is set to be 1 . users need to be cautious with the operation under multi - interrupt situation. ? example: sio interrupt request setup. b0bset f sio ien ; e nable sio interrupt service b0bclr f sio irq ; c lear sio interrupt request flag b0bset fgie ; enable gie ? example: sio interrupt service routine. org 11h ; interrupt vector jmp int_service int_service: b0bts1 fsioirq ; check sioirq jmp exit_int ; sioirq = 0, exit interrupt vector b 0bclr fsioirq ; reset sioirq ; sio interrupt service routine
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 77 vers ion 1. 4 6.14 uart interrupt opera tion when the uart transmitter successfully, the urxirq /utxirq will be set to 1 no matter the urxien/utxien is enable or disable. if the urxien/utxien and the trigger event urxirq/utxirq is set to be 1 . as the result, the system will execute the interrupt vector. if the urxien/utxien = 0, the trigger even t urxirq/utxirq is still set to be 1 . moreover, the system won t execute interrupt vector even when the urxien/utxien is set to be 1 . users need to be cautious with the operation under multi - interrupt situation. ? example: uart receive and transmit int errupt request setup. b0bset f urx ien ; e nable uart receive interrupt service b0bclr f urx irq ; c lear uart receive interrupt request flag b0bset f utx ien ; e nable uart transmit interrupt service b0bclr f utx irq ; c lear uart transmit interrupt requ est flag b0bset fgie ; enable gie ? example: uart receive interrupt service routine. org 13h ; interrupt vector jmp int_service int_service: b0bts1 furxirq ; check rxirq jmp exit_ int ; rxirq = 0, exit interrupt vector b0bclr furxirq ; reset rxirq ; uart receive interrupt service routine
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 78 vers ion 1. 4 6.15 multi - interrupt oper ation under certain condition, the software designer uses more than one interrupt requests. processing multi - interrupt request requires setting the priority of the interrupt requests. the irq flags of interrupts are controlled by the interrupt event. neve rtheless, the irq flag 1 doesn t mean the system will execute the interrupt vector. in addition, which means the irq flags can be set 1 by the events without enable the interrupt. once the event occurs, the irq will be logic 1 . the irq and its trigge r event relationship is as the below table. interrupt name trigger event description wakeirq wake - up from power down or green mode p00irq p0.0 trigger controlled by pedge p01irq p0.1 trigger controlled by pedge t0irq t0c overflow tc0irq tc0c overflow tc1irq tc1c overflow tc2irq tc2c overflow t1irq t1ch, t1cl overflow adcirq adc converting end. sioirq sio transmitter successfully . mspirq msp transmitter successfully . rxirq uart transmit successfully . txirq uart receive successfully . for mult i - interrupt conditions, two things need to be taking care of . one is that it i s multi - vector and e ach of interrupts points to unique vector . two is u sers have to define the interrupt vector . the following example shows the way to define the interrupt vecto r in the program memory . ? example: check the interrupt request under multi - interrupt operation org 8 ; interrupt vector jmp isr_wake jmp isr_int0 jmp isr_int1 jmp isr_t0 jmp isr_tc0 jmp isr_tc1 jmp isr_tc2 jmp isr_t1 jmp isr_adc jmp isr_sio jmp isr_msp jmp isr_uart_rx jmp isr_uart_tx isr_wake: ; wake - up interrupt service routine reti ; exit interrupt vector isr_int0: ; int0 interrupt service routine ; reti ; exit interrupt vector isr_int1: ; int1 interrupt service routine reti ; exit interrupt vector isr_uart_tx: ; uart_tx interrupt service routine reti ; exit interrupt vector
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 79 vers ion 1. 4 7 7 7 i/o port 7.1 overview the micro - controller builds in 27 pin i/o. most of the i/o pins are mixed with analog pins and special function pins. the i/o shared pin list is as following. i/o pin shared pin shared pin control condition name type name type p0.0 i/o int0 dc p00ien=1 tc0 dc tc0cks=1, tc0enb=1 p0.1 i/o int1 dc p01ien =1 tc1 dc tc1cks=1, tc1enb=1 p0.2 i/o urx dc urxen=1 tc2 dc tc2cks=1, tc2enb=1 p0.3 i/o utx dc utxen=1 t1 dc t1cks=1, t1enb=1 p0.4 i/o rst dc reset_pin code option = reset p0. 5 i/o xout ac high_clk code option = ihrc_rtc, 32k, 4m, 12m p0. 6 i/ o xin ac high_clk code option = ihrc_rtc, rc, 32k, 4m, 12m p1.0 i/o eick dc embedded ice mode. p1.1 i/o eida dc embedded ice mode. p1.2 i/o sda dc mspenb=1 p1.3 i/o scl dc mspenb=1 p1.4 i/o sdo dc senb=1 p1.5 i/o sdi dc senb=1 p1.6 i/o sck dc senb=1 p1.7 i/o scs dc senb=1 p4[7:0] i/o ain[7:0] ac adenb=1,gchs=1,chs[3:0]=0000b~0111b p5.0 i/o ain[8] ac adenb=1,gchs=1,chs[3:0]=1000b p5.1 i/o ain[9] ac adenb=1,gchs=1,chs[3:0]=1001b pwm0 dc tc0enb=1, pwm0out=1 p5.2 i/o ain[10] ac adenb=1,gchs=1,chs [3:0]=1010b pwm1 dc tc0enb=1, pwm1out=1 p5.3 i/o ain[11] ac adenb=1,gchs=1,chs[3:0]=1011b pwm2 dc tc0enb=1, pwm2out=1 * dc: digital characteristic. ac: analog characteristic. hv: high voltage characteristic.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 80 vers ion 1. 4 7.2 i/o port mode the port direction i s programmed by pnm register. when the bit of pnm register is 0 , the pin is input mode. when the bit of pnm register is 1 , the pin is output mode. 0a0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 0 m - p 06 m p 05 m p 04 m p 03 m p 02 m p 0 1m p 0 0m read/wr ite - r/w r/w r/w r/w r/w r/w r/w after reset - 0 0 0 0 0 0 0 0a1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 1 m p 17 m p 16 m p 15 m p 14 m p 13 m p 12 m p 11 m p 10 m read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0a4h bit 7 bit 6 b it 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 4 m p 47 m p 46 m p 45 m p 44 m p 43 m p 4 2m p 41 m p 4 0m read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0a5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 5 m - - - - p 5 3m p 52 m p 51 m p 50 m read/write - - - - r/w r/w r/w r/w after reset - - - - 0 0 0 0 bit [7:0] pnm[7:0]: pn mode control bits. (n = 0~5). 0 = pn is input mode. 1 = pn is output mode. ? note : users can program them by bit control instructions (b0bset, b0bclr). ? example: i/o mode sel ecting clr p0m ; set all ports to be input mode. clr p4m clr p5m mov a, #0ffh ; set all ports to be output mode. b0mov p0m, a b0mov p4m,a b0mov p5m, a b0bclr p4m.0 ; set p4.0 to be input mode. b0bset p4m.0 ; set p4.0 to be out put mode.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 81 vers ion 1. 4 7.3 i/o pull up register the i/o pins build in internal pull - up resistors and only support i/o input mode. the port internal pull - up resistor is programmed by pnur register. when the bit of pnur register is 0 , the i/o pin s pull - up is disabled . when the bit of pnur register is 1 , the i/o pin s pull - up is enabled. 0ach bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 0 ur - p 06 r p 05 r p 04 r p 03 r p 02 r p 01 r p 00 r read/write - r/ w r/ w r/ w r/ w r/ w r/ w r/ w after reset - 0 0 0 0 0 0 0 0adh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 1 ur p 17 r p 16 r p 15 r p 14 r p 13 r p 12 r p 11 r p 10 r read/write r/ w r/ w r/ w r/ w r/ w r/ w r/ w r/ w after reset 0 0 0 0 0 0 0 0 0b0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 4 ur p 47 r p 46 r p 45 r p 44 r p 43 r p 42 r p 41 r p 40 r read/write r/ w r/ w r/ w r/ w r/ w r/ w r/ w r/ w after reset 0 0 0 0 0 0 0 0 0b1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 5 ur p 53 r p 52 r p 51 r p 50 r read/write r/ w r/ w r/ w r/ w after reset 0 0 0 0 ? example: i/o pull up register mov a, #0ffh ; enable p or t0, 4, 5 pull - up register, b0mov p 0 ur , a ; b0mov p4ur,a b0mov p 5 ur , a
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 82 vers ion 1. 4 7.4 i/o port data regist er 0a6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0 - p06 p05 p04 p03 p02 p01 p00 read/write - r/w r/w r/w r /w r/w r/ w r/w after reset - 0 0 0 0 0 0 0 0a7h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 1 p17 p16 p15 p14 p13 p12 p11 p10 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0aah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 4 p47 p46 p45 p44 p43 p42 p41 p40 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0abh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5 p 5 3 p 52 p 51 p 50 read/write r/w r/w r/w r/w after reset 0 0 0 0 ? note : the p04 keeps 1 when external reset enable by code option. ? example: read data fro m input port. b0mov a, p0 ; read data from port 0 b0mov a, p4 ; read data from port 4 b0mov a, p5 ; read data from port 5 ? example: write data to output port. mov a, #0ffh ; write data ffh to all port. b0mov p0, a b0mov p4, a b0mov p5, a ? example: write one bit data to output port. b0bset p4.0 ; set p4.0 and p5.3 to be 1 . b0bset p5.3 b0bclr p4.0 ; set p4.0 and p5.3 to be 0 . b0bclr p5.3
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 83 vers ion 1. 4 7.5 p ort 4, port 5 adc sh are pin the port 4, port 5 are shared with adc input function and no schmitt trigger structure. only one pin of port 4, port 5 can be configured as adc input in the same time by adm register. the other pins of port 4, port 5 are digita l i/o pins. connect an analog signal to coms digital input pin, especially the analog signal level is about 1/2 vdd will cause extra current leakage. in the power down mode, the above leakage current will be a big problem. unfortunate ly, if users connect m ore than one analog input signal to port 4 or port 5 will encounter above current leakage situation. p4con is port4 configuration register. p 5 con is port 5 configuration register. write 1 into p4con.n or p5con.n will configure related port 4 or port 5 pin will be set as input mode and disable pull - up resistor. 0c6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4con p4con7 p4con6 p4con5 p4con4 p4con3 p4con2 p4con1 p4con0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7: 0] p4con [ 7:0]: p4.n configuration control bits. 0 = p4.n can be a digital i/o pin. 1 = p4.n will be set as input mode and disable pull - up resistor. 0c7h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5con p5con3 p5con2 p5con1 p5con0 read/wri te r/w r/w r/w r/w after reset 0 0 0 0 bit [3:0] p5con [ 3:0]: p5.n configuration control bits. 0 = p 5 .n can be a digital i/o pin. 1 = p 5 .n will be set as input mode and disable pull - up resistor. port 4 and port 5 adc analog input is contro lled by gchs and chsn bits of adm register. if gchs = 0, p4.n and p5.n are general purpose bi - direction i/o port. if gchs = 1, p4.n and p5.n pointed by chsn is adc analog signal input pin. 0c8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adm adenb a ds eoc gchs chs3 chs2 chs1 chs0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 4 gchs: global channel select bit. 0 = disable ain channel. 1 = enable ain channel. bit [3:0] chs [ 3:0]: adc input channels select bit. 0 000 = ain0, 0001 = ain1, 0010 = ain2, 0011 = ain3, 0100 = ain4, 0101 = ain5, 0110 = ain6, 0111 = ain7, 1000 = ain8, 1001 = ain9, 1010 = ain10, 1011 = ain11. ? note : for p4.n and p5.n general purpose i/o function, users should make sure of p4.n and p5.n s adc channel are disabled, or p4.n and p5.n are automatically set as adc analog input when gchs = 1 and chs[3:0] point to p4.n and p5.n.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 84 vers ion 1. 4 ? example: set p4.1 to be general purpose input mode. p4con.1 must be set as 0 . ; check gchs and chs [ 3:0] status . b0bclr fgchs ;if chs[3:0] point to p4.1 (chs[3:0] = 0001b), set gchs=0 ;if chs[3:0] dont dont ; clear p4con. b0bclr p4con.1 ; enable p4.1 digital function. ; enable p4.1 input mode. b0bclr p4m.1 ; set p4.1 as input mode. ? example: set p4.1 to be general purpose output. p4con.1 must be set as 0 . ; check gchs and chs [ 3:0] status. b0bclr fgchs ; if chs [ 3:0] point to p4.1 ( chs [ 3:0] = 0001b), set gchs=0. ; if chs [ 3:0] dont dont ; clear p4con. b0bclr p4con.1 ; enable p4.1 d igital function. ; set p4.1 output buffer to avoid glitch. b0bset p4.1 ; set p4.1 buffer as 1 . ; or b0bclr p4.1 ; set p4.1 buffer as 0 . ; enable p4.1 output mode. b0bset p4m.1 ; set p4.1 as input mode.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 85 vers ion 1. 4 7.6 open - drain register p0.2 , p0.3, p1.0~p1.7 built in open - drain function. these pins must be set as output mode when enable open - drain function. open - drain external circuit is as following. the pull - up resistor is necessary. open - drain output high is driven by pull - up resistor. output low is sunken by mcu s pin. 09ch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 0oc - - - - - - p 03oc p 02oc read/write - - - - - - r/ w r/ w after reset - - - - - - 0 0 bit [1:0] p02oc, p03oc : p0.2, p0.3 open - drain control bit 0 = d isable op en - drain mode 1 = e nable open - drain mode 09dh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p 1oc p17oc p16oc p15oc p14oc p13oc p12oc p11oc p10oc read/write r/ w r/ w r/ w r/ w r/ w r/ w r/ w r/ w after reset 0 0 0 0 0 0 0 0 bit [7:0] p10oc~p17oc : p1.0~p1.7 open - drain control bit 0 = d isable open - drain mode 1 = e nable open - drain mode ? example: enable p1.0 to open - drain mode and output high. b0bset p1.0 ; set p1.0 buffer high. b0bset p10m ; enable p1.0 output mode. b0bset p10oc ; enable p 1.0 ope n - drain function. ? example: disable open - drain mode. b0bclr p10oc ; disable p 1.0 open - drain function. ? note : after disable open - drain function , i/o mode returns to last i/o mode. u mcu2 u v cc open-drain pin open-drain pin mcu1 p ul l -up re si stor
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 86 vers ion 1. 4 8 8 8 timer s 8.1 watchdog timer the watchdog timer (wdt) is a binary up cou nter designed for monitoring program execution. if the program g oe s into the unknown status by noise interference, watchdog timer overflow signal raises and resets mcu. watchdog timer clock source is internal low - speed oscillator 16khz rc type and through programmable pre - scaler controlled by wdt_clk code option. watchdog timer interval time = 256 * 1/ (internal low - speed oscillator frequency/wdt pre - scalar) sec = 256 / (16khz/wdt pre - scaler) sec internal low - speed oscill ator wdt pre - scaler watchdog interval time flosc=16khz flosc/4 256/(16000/4)=64ms flosc/8 256/(16000/8)=128ms flosc/16 256/(16000/16)=256ms flosc/32 256/(16000/32)=512ms the watchdog timer has three operating options controlled watchdog code opt ion. ? disable: disable watchdog timer function. ? enable: enable watchdog timer function. watchdog timer actives in normal mode and slow mode. in power down mode and green mode, the watchdog timer stops. ? always_on: enable watchdog timer function. the watc hdog timer actives and not stop in power down mode and green mode. ? note : in high noisy environment, the always_on option of watchdog operations is the strongly recommend ation to make the system reset under error situations and re - start again. watc hdog clear is controlled by wdtr register. moving 0x5a data into wdtr is to reset watchdog timer. 096h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 wdtr wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 example : an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: mov a, #5ah ; clear the watchdog timer . b0mov wdtr, a
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 87 vers ion 1. 4 ? example : clear watchdog timer by @rst_wdt macro of sonix ide. main: @rst_wdt ; clear the watchdog timer . watchdog timer application note is as following. ? before clearing watch dog timer, check i/o status and check ram contents can improve system error. ? dont clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. ? clearing watchdog timer program is only at one part of the progra m. this way is the best structure to enhance the watchdog timer function. ? example : an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: dont mov a, #5ah ; clear the watchdo g timer . b0mov wdtr, a call sub1 call sub2
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 88 vers ion 1. 4 8.2 t0 8 - bit basic timer 8.2.1 overview the t0 timer is an 8 - bit binary up timer with basic timer function. the basic timer function supports flag indicator (t0irq bit) an d interrupt operation (interrupt vector). the interval time is programmable through t0m, t0c registers and supports rtc function . the t0 builds in green mode wake - up function. when t0 timer overflow occurs under green mode, the system will be waked - up to l ast operating mode. ? 8 - bit programmable up counting timer: generate time - out at specific time intervals based on the selected clock frequency. ? interrupt function: t0 timer function supports interrupt function. when t0 timer occurs overflow, the t0irq acti ves and the system points program counter to interrupt vector to do interrupt sequence. ? rtc function: t0 supports rtc function . t he rtc clock source is from external low speed 32k oscillator when t0tb=1. rtc function is only available in high_clk code opt ion = "ihrc_rtc" . ? green mode function: t0 timer keeps running in green mode and wake s up system when t0 timer overflows. ? note: in rtc mode, the t0 interval time is fixed at 0.5 sec and t0c is 256 counts. f c p u t 0 r a t e ( f c p u / 2 ~ f c p u / 2 5 6 ) t 0 e n b c p u m 0 , 1 t 0 c 8 - b i t b i n a r y u p c o u n t i n g c o u n t e r t 0 e n b r t c t 0 t b l o a d t 0 c v a l u e b y p r o g r a m . t 0 i r q i n t e r r u p t f l a g ( t 0 t i m e r o v e r f l o w . )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 89 vers ion 1. 4 8.2.2 t0 timer oper ation t0 timer is controlled by t0 enb bit. when t0 enb= 0 , t0 timer stops. when t0enb=1, t0 timer starts to count. t0c increases 1 by timer clock source. when t0 overflow event occurs, t0irq flag is set as 1 to indicate overflow and cleared by program. t he overflow condition is t0c count from full scale (0xff) to zero scale (0x00). t0 doesn t build in double buffer, so load t0c by program when t0 timer overflows to fix the correct interval time. if t0 timer interrupt function is enabled (t0ien=1), the sys tem will execute interrupt procedure. the interrupt procedure is system program counter points to interrupt vector (org 000bh) and executes interrupt service routine after t0 overflow occurrence. clear t0irq by program is necessary in interrupt procedure. t0 timer can works in normal mode, slow mode and green mode. in green mode, t0 keeps counting, set t0irq and wakes up system when t0 timer overflows. t0 clock source is fcpu (instruction cycle) through t0 rate[2:0] pre - scal a r to decide fcpu/2~fcpu/256. t0 length is 8 - bit (256 steps), and the one count period is each cycle of input clock. t0 rate[2:0] t0 clock t0 interval time fhosc=16mhz, fcpu=fhosc/ 4 fhosc=4mhz, fcpu=fhosc/4 ihrc_rtc mode max. (ms) unit (us) max. (ms) unit (us) max. ( sec ) unit ( ms ) 000b fcpu/ 256 16.384 64 65.536 256 - - 001b fcpu/ 128 8.192 32 32.768 128 - - 010b fcpu/ 64 4.096 16 16.384 64 - - 011b fcpu/ 32 2.048 8 8.192 32 - - 100b fcpu/ 16 1.024 4 4. 096 1 6 - - 101b fcpu/ 8 0.512 2 2.048 8 - - 110b fcpu/ 4 0.256 1 1.024 4 - - 111b fcpu/ 2 0.128 0.5 0.512 2 - - - 32768hz/64 - - - - 0.5 1.953 0 x 0 0 o r n b y p r o g r a m . . . . . . c l o c k s o u r c e t 0 c t 0 i r q t 0 t i m e r o v e r f l o w s . t 0 i r q s e t a s 1 . r e l o a d t 0 c b y p r o g r a m . t 0 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 1 o r n + 1 0 x f e 0 x f f . . . . . . 0 x 0 0 o r n b y p r o g r a m 0 x 0 2 o r n + 2 0 x 0 2 o r n + 2
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 90 vers ion 1. 4 8.2.3 t0m mode register t0 m is t0 timer mode control register to configure t0 operating mode including t0 pre - scaler, clock source these configurations must be set up completely before enabling t0 timer. 0b2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m t0enb t0rate2 t0rate1 t0rate0 - - - t0tb read/write r/w r/w r/w r/w - - - r/w after reset 0 0 0 0 - - - 0 bit 0 t0tb: rtc clock source control bit. 0 = disable rtc (t0 clock source from fcpu). 1 = enable rtc. bit [6:4] t0 rate[2:0]: t0 timer clock source select bits. 000 = fcpu/ 256 , 001 = fcpu/ 128 , 010 = fcpu/ 64 , 011 = fcpu/ 32 , 100 = fcpu/ 16 , 101 = fcpu/ 8 , 110 = fcpu/ 4 , 111 = fcpu/ 2 . bit 7 t0enb: t0 counter control bit. 0 = d isable t0 timer. 1 = enable t0 timer . ? note: t0rate is not available in rtc mode. the t0 interval time is fixed at 0.5 sec. 8.2.4 t0c counting register t0c is t0 8 - bit counter. when t0c overflow occurs, the t0irq flag is set as 1 and cleared by program. the t0c decides t0 interval time through below equation to calculate a correct value. it is necessary to write the correct value to t0c register, and then enable t0 timer to make sure the first cycle correct. after one t0 overfl ow occurs, the t0c register is loaded a correct value by program. 0b3h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0c t0c7 t0c6 t0c5 t0c4 t0c3 t0c2 t0c1 t0c0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t0c initial value is as following. t0c initial value = 256 - (t0 interrupt interval time * t0 clock rate ) ? example: to calculation t0c to obtain 10ms t0 interval time. t0 clock source is fcpu = 4mhz/4 = 1mhz. select t0rate=001 (fcpu/128). t0 interva l time = 10ms. t0 clock rate = 4 mhz/ 4 /128 t0 c initial value = 256 - (t0 interval time * input clock) = 256 - (10ms * 4mhz / 4 / 128 ) = 256 - ( 10 - 2 * 4 * 10 6 / 4 / 128 ) = b2h ? note: in rtc mode, t0c is 256 counts and generatest0 0.5 sec interval time. don t change t0c value in rtc mode.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 91 vers ion 1. 4 8.2.5 t0 timer operation explame ? t0 timer configuration : ; reset t0 timer. mov a, #0x00 ; clear t0 m register. b0mov t0 m, a ; set t0 clock source and t0 rate. mov a, #0 nnn 0 0 00b b0mov t0 m, a ; set t 0 c register for t0 interval time. mov a, # value b0mov t0 c, a ; clear t0 irq b0bclr f t0 irq ; enable t0 timer and interrupt function. b0bset ft0ien ; enable t0 interrupt function. b0bset ft0enb ; enable t0 timer. ? t0 works in rtc mode : ; reset t0 timer. mov a, #0x00 ; clear t0 m register. b0mov t0 m, a ; set t0 rtc function. b0bset ft0tb ; clear t0 c. clr t0c ; clear t0 irq b0bclr f t0 irq ; enable t0 timer and interrupt function. b0bset ft0ie n ; enable t0 interrupt function. b0bset ft0enb ; enable t0 timer.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 92 vers ion 1. 4 8.3 tc0 8 - bit timer/counter 8.3.1 overview the tc0 timer is an 8 - bit binary up timer with basic timer, event counter and pwm functions. the basic timer function supports flag indicator (tc0irq bit) and interrupt operation (interrupt vector). the interval time is programmable through tc0m, tc0c, tc0r registers. the event counter is changing tc0 clock source from system clock (fcpu/fhosc) to external clock like signal (e.g. continuous pulse, r/c t ype oscillating signal ) . tc0 becomes a counter to count external clock number to implement measure application . tc0 also builds in duty/cycle programmable pwm. the pwm cycle and resolution are controlled by tc0 timer clock rate, tc0r and tc0d registers, s o the pwm with good flexibility to implement ir carry signal, motor control and brightness adjuster the main purposes of the tc0 timer are as following. ? 8 - bit programmable up counting timer: generate time - out at specific time intervals based on the select ed clock frequency. ? interrupt function: t c0 timer function support s interrupt function. when t c0 timer occurs overflow, the t c0 irq actives and the system points program counter to interrupt vector to do interrupt sequence. ? event counter: the event counte r function counts the external clock counts. ? duty/cycle programmable pwm : the pwm is duty/cycle programmable controlled by tc0r and tc0d registers. ? green mode function: all tc0 functions (timer, pwm, event counter, auto - reload) keep running in green mode and no wake - up function. t c 0 r a t e ( f c p u / 1 ~ f c p u / 1 2 8 ) p 0 . 0 ( s c h m i t t e r t r i g g e r ) t c 0 c k s 1 t c 0 e n b c p u m 0 , 1 t c 0 c 8 - b i t b i n a r y u p c o u n t i n g c o u n t e r t c 0 r r e l o a d d a t a b u f f e r s r t c 0 t i m e o u t p 5 . 1 g p i o p 5 . 1 p i n p w m p w m 0 o u t l o a d c o m p a r e t c 0 d d a t a b u f f e r u p c o u n t i n g r e l o a d v a l u e f c p u f h o s c t c 0 c k s 0
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 93 vers ion 1. 4 8.3.2 tc0 timer operation tc0 timer is controlled by tc0enb bit. when tc0enb= 0 , tc0 timer stops. when tc0enb=1, tc0 timer starts to count. before enabling tc0 timer, setup tc0 timer s configurations to select timer function modes, e.g. basic timer, interrupt function tc0c increases 1 by timer clock source. when tc0 overflow event occurs, tc0irq flag is set as 1 to indicate overflow and cleared by program. the overflow condition is tc0c count from fu ll scale (0xff) to zero scale (0x00). in difference function modes, tc0c value relates to operation. if tc0c value changing effects operation, the transition of operations would make timer function error. so tc0 builds in double buffer to avoid these situa tions happen. the double buffer concept is to flash tc0c during tc0 counting, to set the new value to tc0r (reload buffer), and the new value will be loaded from tc0r to tc0c after tc0 overflow occurrence automatically. in the next cycle, the tc0 timer run s under new conditions, and no any transitions occur. the auto - reload function is no any control interface and always actives as tc0 enables. if tc0 timer interrupt function is enabled (tc0ien=1), the system will execute interrupt procedure. the interrupt procedure is system program counter points to interrupt vector (org 000ch) and executes interrupt service routine after tc0 overflow occurrence. clear tc0irq by program is necessary in interrupt procedure. tc0 timer can works in normal mode, slow mode and green mode. but in green mode, tc0 keep counting, set tc0irq and outputs pwm, but can t wake - up system. tc0 provides different clock sources to implement different applications and configurations. tc0 clock source includes fcpu (instruction cycle) , fhosc (high speed oscillator) and external input pin (p0.0) controlled by tc0cks[1:0] bits . tc0cks0 bit selects the clock source is from fcpu or fhosc. if tc0cks0=0, tc0 clock source is fcpu through tc0rate[2:0] pre - scal a r to decide f cpu/1~fcpu/128. if tc0cks0=1, tc0 clock source is fhosc through tc0rate[2:0] pre - scal a r to decide fcpu/1~fcpu/128 . tc0cks1 bit controls the clock source is external input pin or controlled by tc0cks0 bit. if tc0cks1=0, tc0 clock source is selected by tc0ck s0 bit. if tc0cks1=1, tc0 clock source is external input pin that means to enable event counter fu nction . tc0rate[2:0] pre - scalar is unless when tc0cks0=1 or tc0cks1=1 conditions. tc0 length is 8 - bit (256 steps), and the one count period is each cycle of i nput clock. tc0cks0 tc0rate[2:0] tc0 clock tc0 interval time fhosc=16mhz, fcpu=fhosc/ 4 fhosc=4mhz, fcpu=fhosc/4 max. (ms) unit (us) max. (ms) unit (us) 0 000b fcpu/ 128 8.192 32 32.768 128 0 001b fcpu/ 64 4.096 16 16.384 64 0 010b fcpu/ 32 2.04 8 8 8.192 32 0 011b fcpu/ 16 1.024 4 4.096 1 6 0 100b fcpu/ 8 0.512 2 2.048 8 0 101b fcpu/ 4 0.256 1 1.024 4 0 110b fcpu/ 2 0.128 0.5 0.512 2 0 111b fcpu/ 1 0.064 0.25 0. 256 1 1 000b fhosc /128 2.048 8 8.192 32 1 001b fhosc /64 1.024 4 4.096 16 1 010b fhos c /32 0.512 2 2.048 8 1 011b fhosc /16 0.256 1 1.024 4 1 100b fhosc /8 0.128 0.5 0.512 2 1 101b fhosc /4 0.064 0.25 0.256 1 1 110b fhosc /2 0.032 0.125 0.128 0.5 1 111b fhosc /1 0.016 0.0625 0.064 0.25 0 x 0 0 o r t c 0 r . . . . . . c l o c k s o u r c e t c 0 c t c 0 i r q t c 0 t i m e r o v e r f l o w s . t c 0 i r q s e t a s 1 . r e l o a d t c 0 c f r o m t c 0 r a u t o m a t i c a l l y . t c 0 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 1 0 x 0 2 0 x 0 3 0 x f e 0 x f f t c 0 r . . . . . .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 94 vers ion 1. 4 8.3.3 tc0m mode register tc0m is tc0 timer mode control r egister to configure tc0 operating mode including tc0 pre - scal a r, clock source, pwm function these configurations must be setup completely before enabling tc0 timer. 0b4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0m tc0enb tc0rate2 tc0rate1 tc0r ate0 tc0cks1 tc0cks0 - pwm0out read/write r/w r/w r/w r/w r/w r/w - r/w after reset 0 0 0 0 0 0 - 0 bit 0 pwm0out: pwm output control bit. 0 = disable pwm output function, and p5.1 is gpio mode. 1 = enable pwm output function, and p5.1 outputs pwm s ignal. bit 2 tc0cks0: tc0 clock source select bit. 0 = fcpu. 1 = fhosc. bit 3 tc0cks1: tc0 clock source select bit. 0 = internal clock ( fcpu and fhosc controlled by tc0cks0 bit ) . 1 = external input pin (p0.0/int0) and enable event counter function . tc0rate[2:0] bits are useless. bit [6:4] t c0 rate[2:0]: t c0 timer clock source select bits. t c0 cks0=0 - > 000 = fcpu/128, 001 = fcpu/64, 010 = fcpu/32, 011 = fcpu/16, 100 = fcpu/8, 101 = fcpu/4, 110 = fcpu/2,111 = fcpu/1. tc0 cks0=1 - > 000 = f hosc /128, 00 1 = f hosc /64, 010 = f hosc /32, 011 = f hosc /16, 100 = f hosc /8, 101 = f hosc /4, 110 = f hosc /2,111 = f hosc /1. bit 7 t c 0enb: t c 0 counter control bit. 0 = d isable tc0 timer. 1 = enable tc0 timer . 8.3.4 tc0c counting register tc0c is tc0 8 - bit counter. when tc0c o verflow occurs, the tc0irq flag is set as 1 and cleared by program. the tc0c decides tc0 interval time through below equation to calculate a correct value. it is necessary to write the correct value to tc0c register and tc0r register first time, and then enable tc0 timer to make sure the fist cycle correct. after one tc0 overflow occurs, the tc0c register is loaded a correct value from tc0r register automatically, not program. 0b5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0c tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t c 0c initial value is as following. t c 0c initial value = 256 - (t c 0 interrupt interval time * tc0 clock rate )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 95 vers ion 1. 4 8.3.5 tc0 r auto - reload r egister tc0 timer builds in auto - reload function, and tc0r register stores reload data. when tc0c overflow occurs, tc0c register is loaded data from tc0r register automatically. under tc0 timer counting status, to modify tc0 interval time is to modify tc0r register, not tc0c register . n ew tc0c data of tc0 interval time will be updated after tc0 timer overflow occurrence, tc0r loads new value to tc0c register. but at the first time to setup tc0m, tc0c and tc0r must be set the same value before enabling tc0 t imer. tc0 is double buffer design. if new tc0r value is set by program, the new value is stored in 1 st buffer. until tc0 overflow occurs, the new value moves to real tc0r buffer. this way can avoid any transitional condition to affect the correctness of tc 0 interval time and pwm output signal. 0b6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0 r tc0 r 7 tc0 r 6 tc0 r 5 tc0 r 4 tc0 r 3 tc0 r 2 tc0 r 1 tc0 r 0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the equation of t c 0 r initial value is as followin g. t c 0 r initial value = 256 - (t c 0 interrupt interval time * tc0 clock rate ) ? example: to calculation tc0c and tc0r value to obtain 10ms tc0 interval time. tc0 clock source is fcpu = 16mhz/16 = 1mhz. select tc0rate=000 (fcpu/128). tc0 interval time = 10ms. tc0 clock rate = 16 mhz/ 16 /128 tc0c/ t c 0 r initial value = 256 - (t c 0 interval time * input clock) = 256 - (10ms * 16mhz / 16 / 128 ) = 256 - ( 10 - 2 * 16 * 10 6 / 16 / 128 ) = b2h 8.3.6 tc0 d pwm duty register tc0d register s purpose is to decide pwm duty. in pwm mode, tc0r controls pwm s cycle, and tc0d controls the duty of pwm. the operation is base on timer counter value. w h en tc0c = tc0d, the pwm high duty finished and exchange to low level. it is easy to configure tc0d to choose the right pwm s duty for ap plication. 0 b7 h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t c 0 d t c 0 d 7 t c 0 d 6 t c 0 d 5 t c 0 d 4 t c 0 d 3 t c 0 d 2 t c 0 d 1 t c 0 d 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t c 0 d initial value is as following. t c 0 d i nitial value = tc0r + ( pwm high pulse width period / tc0 clock rate ) ? example: to calculate tc0d value to obtain 1/3 duty pwm signal. the tc0 clock source is fcpu = 16mhz/16= 1mhz. select tc0rate=000 (fcpu/128). tc0 r = b2h . tc0 interval time = 10ms. so the pwm cycle is 100hz. in 1/3 duty condition, the high pulse width is about 3.33ms. tc0d initial value = b2h + ( pwm high pulse width period / t c 0 clock rate ) = b2h + ( 3.33 ms * 16mhz / 16 / 128) = b2h + 1ah = cch
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 96 vers ion 1. 4 8.3.7 tc0 ev ent counter tc0 event counter is set the tc0 clock source from external input pin (p0.0). when tc0cks1=1, tc0 clock source is switch to external input pin (p0.0). tc0 event counter trigger direction is falling edge. when one falling edge occurs, tc0c will up one count. when tc0c counts f rom 0xff to 0x00, tc0 triggers overflow event. the external event counter input pins wake - up function of gpio mode is disabled when tc0 event counter function enabled to avoid event counter signal trigger system wake - up and not keep in power saving mode. the external event counter input pins external interrupt function is also disabled when tc0 event counter function enabled , and the p00irq bit keeps 0 status. the event counter usually is used to measure external continuous signal rate, e.g. continuous pulse, r/c type oscillating signal these signal phase don t synchronize with mcu s main clock. use tc0 event to measure it and calculate the signal rate in program for different applications. 8.3.8 pulse width modulation (pwm) the pwm is duty/cycle programmable design to offer various pwm signals. when tc0 timer enables and pwm0out bit sets as 1 (enable pwm output), the pwm output pin (p5.1) outputs pwm signal. one cycle of pwm signal is high pulse first, and then low pulse output s. tc0r register controls the cycle of pwm, and tc0d decides the duty (high pulse width length) of pwm. tc0c initial value is tc0r reloaded when tc0 timer enables and tc0 timer overflows. when tc0c count is equal to tc0d, the pwm high pulse finishes and ex changes to low level. when tc0 overflows (tc0c counts from 0xff to 0x00), one complete pwm cycle finishes. the pwm exchanges to high level for next cycle. the pwm is auto - reload design to load tc0c from tc0r automatically when tc0 overflows and the end of pwm s cycle, to keeps pwm continuity. if modify the pwm cycle by program as pwm outputting , the new cycle occurs at next cycle when tc0c loaded from tc0r. the resolution of pwm is decided by tc0r. tc0r range is from 0x00~0xff. if tc0r = 0x00, pwm s resolution is 1/256. if tc0r = 0x80, pwm s resolution is 1/128. tc0d controls the high pulse width of pwm for pwm s duty. when tc0c = tc0d, pwm output exchanges to low status. tc0d must be greater than tc0r, or the pwm signal keeps l ow status. when pwm outputs, tc0irq still actives as tc0 overflows, and tc0 interrupt function actives as tc0ien = 1. but strongly recommend be careful to use pwm and tc0 timer together, and make sure both functions work well. the pwm output pin is shared with gpio and switch to output pwm signal as pwm0out=1 automatically. if pwm0out bit is cleared to disable pwm, the output pin exchanges to last gpio mode automatically. it easily to implement carry signal on/off operation, not to control tc0enb bit. 0 x 0 0 o r t c 0 r . . . . . . e x t e r n a l i n p u t s i g n e l t c 0 c t c 0 i r q t c 0 t i m e r o v e r f l o w s . t c 0 i r q s e t a s 1 . r e l o a d t c 0 c f r o m t c 0 r a u t o m a t i c a l l y . t c 0 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 1 0 x 0 2 0 x 0 3 0 x f e 0 x f f t c 0 r . . . . . . t c 0 r t c 0 r + 1 t c 0 r + 2 t c 0 c . . . t c 0 d - 2 t c 0 d - 1 t c 0 d p w m o u t p u t . . . 0 x f d 0 x f e 0 x f f t c 0 r t c 0 r + 1 t c 0 r + 2 . . . e n a b l e t c 0 a n d p w m . t c 0 c i s l o a d e d f r o m t c 0 r . p w m o u t p u t s h i g h s t a t u s . t c 0 c = t c 0 d . p w m e x c h a n g e s t o l o w s t a t u s . t c 0 c o v e r f l o w s f r o m 0 x f f t o 0 x 0 0 . t c 0 c i s l o a d e d f r o m t c 0 r . p w m e x c h a n g e s t o h i g h s t a t u s . o n e c o m p l e t e c y c l e o f p w m . n e x t c y c l e .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 97 vers ion 1. 4 8.3.9 tc0 timer operation explame ? tc0 timer configuration : ; reset tc0 timer. clr tc0m ; clear tc0m register. ; set tc0 clock source and tc0 rate. mov a, #0 nnn 0 n 00b b0mov tc0m, a ; set tc0c and tc0r register f or tc0 interval time. mov a, # value ; tc0c must be equal to tc0r. b0mov tc0c, a b0mov tc0r, a ; clear tc0irq b0bclr ftc0irq ; enable tc0 timer and interrupt function. b0bset ftc0ien ; enable tc0 interrupt function. b0bset ftc 0enb ; enable tc0 timer. p w m o u t p u t p w m 0 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 0 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( o u t p u t l o w ) . p w m 0 o u t = 1 . p w m 0 o u t = 0 . p w m o u t p u t p w m 0 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 0 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( o u t p u t h i g h ) . p w m 0 o u t = 1 . p w m 0 o u t = 0 . p w m o u t p u t p w m 0 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 0 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( i n p u t ) . p w m 0 o u t = 1 . p w m 0 o u t = 0 . h i g h i m p e n d e n c e ( f l o a t i n g )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 98 vers ion 1. 4 ? tc0 event counter configuration : ; reset tc0 timer. clr tc0m ; clear tc0m register. ; enable tc0 event counter . b0bset ftc0cks1 ; set tc0 clock source from external input pin (p0.0). ; set tc0c and tc0r regis ter for tc0 interval time. mov a, # value ; tc0c must be equal to tc0r. b0mov tc0c, a b0mov tc0r, a ; clear tc0irq b0bclr ftc0irq ; enable tc0 timer and interrupt function. b0bset ftc0ien ; enable tc0 interrupt function. b0bse t ftc0enb ; enable tc0 timer. ? tc0 pwm configuration : ; reset tc0 timer. clr tc0m ; clear tc0m register. ; set tc0 clock source and tc0 rate. mov a, #0 nnn 0 n 00b b0mov tc0m, a ; set tc0c and tc0r register for pwm cycle . mov a, # val ue 1 ; tc0c must be equal to tc0r. b0mov tc0c, a b0mov tc0r, a ; set tc0d register for pwm duty. mov a, # value 2 ; tc0d must be greater than tc0r. b0mov tc0 d , a ; enable pwm and tc0 timer . b0bset ftc0enb ; enable tc0 timer. b0bs et fpwm0out ; enable pwm.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 99 vers ion 1. 4 8.4 tc1 8 - bit timer/counter 8.4.1 overview the tc 1 timer is an 8 - bit binary up timer with basic timer, event counter and pwm functions. the basic timer function supports flag indicator (tc1irq bit) and interrupt operation (interrupt vec tor). the interval time is programmable through tc1m, tc1c, tc1r registers. the event counter is changing tc 1 clock source from system clock (fcpu/fhosc) to external clock like signal (e.g. continuous pulse, r/c type oscillating signal ) . tc1 becomes a cou nter to count external clock number to implement measure application . tc1 also builds in duty/cycle programmable pwm. the pwm cycle and resolution are controlled by tc1 timer clock rate, tc1r and tc1d registers, so the pwm with good flexibility to implemen t ir carry signal, motor control and brightness adjuster the main purposes of the tc 1 timer are as following. ? 8 - bit programmable up counting timer: generate time - out at specific time intervals based on the selected clock frequency. ? interrupt function: tc 1 timer function support s interrupt function. when tc1 timer occurs overflow, the tc1 irq actives and the system points program counter to interrupt vector to do interrupt sequence. ? event counter: the event counter function counts the external clock counts . ? duty/cycle programmable pwm : the pwm is duty/cycle programmable controlled by tc1 r and tc1 d registers. ? green mode function: all tc1 functions (timer, pwm, event counter, auto - reload) keep running in green mode and no wake - up function. t c 1 r a t e ( f c p u / 1 ~ f c p u / 1 2 8 ) t c 1 e n b c p u m 0 , 1 t c 1 c 8 - b i t b i n a r y u p c o u n t i n g c o u n t e r t c 1 r r e l o a d d a t a b u f f e r s r t c 1 t i m e o u t p 5 . 2 g p i o p 5 . 2 p i n p w m p w m 0 o u t l o a d c o m p a r e t c 1 d d a t a b u f f e r u p c o u n t i n g r e l o a d v a l u e f c p u f h o s c t c 1 c k s 0 p 0 . 1 ( s c h m i t t e r t r i g g e r ) t c 1 c k s 1
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 100 vers ion 1. 4 8.4.2 tc1 timer operation tc1 timer is controlled by tc1 enb bit. when tc1 enb= 0 , tc1 timer stops. when tc1enb=1, tc1 timer starts to count. before enabling tc1 timer, setup tc1 timer s configurations to select timer function modes, e.g. basic tim er, interrupt function tc1c increases 1 by timer clock source. when tc1 overflow event occurs, tc1irq flag is set as 1 to indicate overflow and cleared by program. the overflow condition is tc1c count from full scale (0xff) to zero scale (0x00). in dif ference function modes, tc1c value relates to operation. if tc1c value changing effects operation, the transition of operations would make timer function error. so tc1 builds in double buffer to avoid these situations happen. the double buffer concept is t o flash tc1c during tc1 counting, to set the new value to tc1r (reload buffer), and the new value will be loaded from tc1r to tc1c after tc1 overflow occurrence automatically. in the next cycle, the tc1 timer runs under new conditions, and no any transitio ns occur. the auto - reload function is no any control interface and always actives as tc1 enables. if tc1 timer interrupt function is enabled (tc1ien=1), the system will execute interrupt procedure. the interrupt procedure is system program counter points t o interrupt vector (org 000dh) and executes interrupt service routine after tc1 overflow occurrence. clear tc1irq by program is necessary in interrupt procedure. tc1 timer can works in normal mode, slow mode and green mode. but in green mode, tc1 keep coun ting, set tc1irq and outputs pwm, but can t wake - up system. tc1 provides different clock sources to implement different applications and configurations. tc 1 clock source includes fcpu (instruction cycle) , fhosc (high speed osci llator) and external input pin (p0. 1 ) controlled by tc1cks[1:0] bits . tc 1 cks0 bit selects the clock source is from fcpu or fhosc. if tc 1 cks0=0, tc 1 clock source is fcpu through tc 1 rate[2:0] pre - scal a r to decide fcpu/1~fcpu/128. if tc 1 cks0=1, tc0 clock sour ce is fhosc through tc 1 rate[2:0] pre - scal a r to decide fcpu/1~fcpu/128 . tc 1 cks1 bit controls the clock source is external input pin or controlled by tc 1 cks0 bit. if tc 1 cks1=0, tc 1 clock source is selected by tc 1 cks0 bit. if tc 1 cks1=1, tc0 clock source is ex ternal input pin that means to enable event counter fu nction . tc1rate[2:0] pre - scalar is unless when tc1cks0=1 or tc1cks1=1 conditions. tc1 length is 8 - bit (256 steps), and the one count period is each cycle of input clock. tc1cks0 tc 1 rate[2:0] tc 1 clock tc 1 interval time fhosc=16mhz, fcpu=fhosc/ 4 fhosc=4mhz, fcpu=fhosc/4 max. (ms) unit (us) max. (ms) unit (us) 0 000b fcpu/ 128 8.192 32 32.768 128 0 001b fcpu/ 64 4.096 16 16.384 64 0 010b fcpu/ 32 2.048 8 8.192 32 0 011b fcpu/ 16 1.024 4 4.096 1 6 0 100b fcpu/ 8 0.512 2 2.048 8 0 101b fcpu/ 4 0.256 1 1.024 4 0 110b fcpu/ 2 0.128 0.5 0.512 2 0 111b fcpu/ 1 0.064 0.25 0. 256 1 1 000b fhosc /128 2.048 8 8.192 32 1 001b fhosc /64 1.024 4 4.096 16 1 010b fhosc /32 0.512 2 2.048 8 1 011b fhosc /16 0.256 1 1.024 4 1 100b fhosc /8 0.128 0.5 0.512 2 1 101b fhosc /4 0.064 0.25 0.256 1 1 110b fhosc /2 0.032 0.125 0.128 0.5 1 111b fhosc /1 0.016 0.0625 0.064 0.25 0 x 0 0 o r t c 1 r . . . . . . c l o c k s o u r c e t c 1 c t c 1 i r q t c 1 t i m e r o v e r f l o w s . t c 1 i r q s e t a s 1 . r e l o a d t c 1 c f r o m t c 1 r a u t o m a t i c a l l y . t c 1 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 1 0 x 0 2 0 x 0 3 0 x f e 0 x f f t c 1 r . . . . . .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 101 vers ion 1. 4 8.4.3 tc1m mode register tc1 m is tc1 timer mode control register to configure tc1 operating mode incl uding tc1 pre - scalar, clock source, pwm function these configurations must be setup completely before enabling tc1 timer. 0b8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1 m tc1 enb tc1 rate2 tc1 rate1 tc1 rate0 tc1 cks 1 tc1 cks0 - pwm1 out read/write r /w r/w r/w r/w r/w r/w - r/w after reset 0 0 0 0 0 0 - 0 bit 0 pwm1out: pwm output control bit. 0 = disable pwm output function, and p5.2 is gpio mode. 1 = enable pwm output function, and p5.2 outputs pwm signal. bit 2 tc1 cks0: tc1 clock source sel ect bit. 0 = fcpu. 1 = fhosc. bit 3 tc 1 cks1: tc 1 clock source select bit. 0 = internal clock ( fcpu and fhosc controlled by tc 1 cks0 bit ) . 1 = external input pin (p0. 1 /int 1 ) and enable event counter function. tc0rate[2:0] bits are useless. bit [6:4] t c 1 rate[2:0]: t c1 timer clock source select bits. t c1 cks0=0 - > 000 = fcpu/128, 001 = fcpu/64, 010 = fcpu/32, 011 = fcpu/16, 100 = fcpu/8, 101 = fcpu/4, 110 = fcpu/2,111 = fcpu/1. tc1 cks0=1 - > 000 = f hosc /128, 001 = f hosc /64, 010 = f hosc /32, 011 = f hosc /16, 100 = f hosc /8, 101 = f hosc /4, 110 = f hosc /2,111 = f hosc /1. bit 7 tc1enb: tc1 counter control bit. 0 = d isable tc1 timer. 1 = enable tc1 timer . 8.4.4 tc1c counting register tc1c is tc1 8 - bit counter. when tc1c overflow occurs, the tc1irq flag is set as 1 and cleared by program. the tc1c decides tc1 interval time through below equation to calculate a correct value. it is necessary to write the correct value to tc1c register and tc1r register first time, and then enable tc1 timer to make sure the fist cycle correct. after one tc1 overflow occurs, the tc1c register is loaded a correct value from tc1r register automatically, not program. 0b9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1c tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of tc1c initial value is as following. tc1c initial value = 256 - (tc1 interrupt interval time * tc1 clock rate )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 102 vers ion 1. 4 8.4.5 tc1 r auto - reload register tc1 timer builds in auto - reload functi on, and tc1r register stores reload data. when tc1c overflow occurs, tc1c register is loaded data from tc1r register automatically. under tc1 timer counting status, to modify tc1 interval time is to modify tc1r register, not tc1c register . n ew tc1c data of tc1 interval time will be updated after tc1 timer overflow occurrence, tc1r loads new value to tc1c register. but at the first time to setup t0m, tc1c and tc1r must be set the same value before enabling tc1 timer. tc1 is double buffer design. if new tc1r value is set by program, the new value is stored in 1 st buffer. until tc1 overflow occurs, the new value moves to real tc1r buffer. this way can avoid any transitional condition to affect the correctness of tc1 interval time and pwm output signal. 0bah b it 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1 r tc1 r 7 tc1 r 6 tc1 r 5 tc1 r 4 tc1 r 3 tc1 r 2 tc1 r 1 tc1 r 0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the equation of tc1 r initial value is as following. tc1 r initial value = 256 - (tc1 interrupt interval time * tc1 clock rate ) ? example: to calculation tc1c and tc1r value to obtain 10ms tc1 interval time. tc1 clock source is fcpu = 16mhz/16 = 1mhz. select tc1rate=000 (fcpu/128). tc1 interval time = 10ms. tc1 clock rate = 16 mhz/ 16 /128 tc1c/ tc1 r initial value = 256 - (tc1 interval time * input clock) = 256 - (10ms * 16mhz / 16 / 128 ) = 256 - ( 10 - 2 * 16 * 10 6 / 16 / 128 ) = b2h 8.4.6 tc1 d pwm duty register tc1d register s purpose is to decide pwm duty. in pwm mode, tc1r controls pwm s cycle, and tc1d c ontrols the duty of pwm. the operation is base on timer counter value. w h en tc1c = tc1d, the pwm high duty finished and exchange to low level. it is easy to configure tc1d to choose the right pwm s duty for application. 0 bb h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1 d tc1 d 7 tc1 d 6 tc1 d 5 tc1 d 4 tc1 d 3 tc1 d 2 tc1 d 1 tc1 d 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of tc1 d initial value is as following. tc1 d initial value = tc1r + ( pwm high pulse width per iod / tc1 clock rate ) ? example: to calculate tc1d value to obtain 1/3 duty pwm signal. the tc1 clock source is fcpu = 16mhz/16 = 1mhz. select tc1rate=000 (fcpu/128). tc1r = b2h . tc1 interval time = 10ms. so the pwm cycle is 100hz. in 1/3 duty condition , the high pulse width is about 3.33ms. tc1d initial value = b2h + ( pwm high pulse width period / tc1 clock rate ) = b2h + ( 3.33 ms * 16mhz / 16 / 128) = b2h + 1ah = cch
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 103 vers ion 1. 4 8.4.7 tc 1 ev ent counter tc 1 event counter is set the tc 1 clock source from external input p in (p0. 1 ). when tc 1 cks1=1, tc 1 clock source is switch to external input pin (p0. 1 ). tc 1 event counter trigger direction is falling edge. when one falling edge occurs, tc 1 c will up one count. when tc 1 c counts from 0xff to 0x00, tc 1 triggers overflow event. the external event counter input pins wake - up function of gpio mode is disabled when tc 1 event counter function enabled to avoid event counter signal trigger system wake - up and not keep in power saving mode. the external event counter input pins external interrupt function is also disabled when tc 1 event counter function enabled , and the p01irq bit keeps 0 status. the event counter usually is used to measure external continuous signal rate, e.g. continuous pulse, r/c type oscillating signal these signal phase don t synchronize with mcu s main clock. use tc1 event to measure it and calculate the signal rate in program for different applications. 8.4.8 pulse width modulation (pwm) the pwm is duty/cycle programmable design to offer various pwm signals. when tc1 timer enables and pwm1out bit sets as 1 (enable pwm output), the pwm output pin (p5.2) outputs pwm signal. one cycle of pwm signal is high pulse first, and then low pulse outputs. tc1r register controls the cycle of pwm, an d tc1d decides the duty (high pulse width length) of pwm. tc1c initial value is tc1r reloaded when tc1 timer enables and tc1 timer overflows. when tc1c count is equal to tc1d, the pwm high pulse finishes and exchanges to low level. when tc1 overflows (tc1c counts from 0xff to 0x00), one complete pwm cycle finishes. the pwm exchanges to high level for next cycle. the pwm is auto - reload design to load tc1c from tc1r automatically when tc1 overflows and the end of pwm s cycle, to keeps pwm continuity. if modif y the pwm cycle by program as pwm outputting , the new cycle occurs at next cycle when tc1c loaded from tc1r. the resolution of pwm is decided by tc1r. tc1r range is from 0x00~0xff. if tc1r = 0x00, pwm s resolution is 1/256. if tc1r = 0x80, pwm s resolution is 1/128. tc1d controls the high pulse width of pwm for pwm s duty. when tc1c = tc1d, pwm output exchanges to low status. tc1d must be greater than tc1r, or the pwm signal keeps low status. when pwm outputs, tc1irq still ac tives as tc1 overflows, and tc1 interrupt function actives as tc1ien = 1. but strongly recommend be careful to use pwm and tc1 timer together, and make sure both functions work well. the pwm output pin is shared with gpio and switch to output pwm signal a s pwm1out=1 automatically. if pwm1out bit is cleared to disable pwm, the output pin exchanges to last gpio mode automatically. it easily to implement carry signal on/off operation, not to control tc1enb bit. 0 x 0 0 o r t c 1 r . . . . . . e x t e r n a l i n p u t s i g n e l t c 1 c t c 1 i r q t c 1 t i m e r o v e r f l o w s . t c 1 i r q s e t a s 1 . r e l o a d t c 1 c f r o m t c 1 r a u t o m a t i c a l l y . t c 1 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 1 0 x 0 2 0 x 0 3 0 x f e 0 x f f t c 1 r . . . . . . t c 1 r t c 1 r + 1 t c 1 r + 2 t c 1 c . . . t c 1 d - 2 t c 1 d - 1 t c 1 d p w m o u t p u t . . . 0 x f d 0 x f e 0 x f f t c 1 r t c 1 r + 1 t c 1 r + 2 . . . e n a b l e t c 1 a n d p w m . t c 1 c i s l o a d e d f r o m t c 1 r . p w m o u t p u t s h i g h s t a t u s . t c 1 c = t c 1 d . p w m e x c h a n g e s t o l o w s t a t u s . t c 1 c o v e r f l o w s f r o m 0 x f f t o 0 x 0 0 . t c 1 c i s l o a d e d f r o m t c 1 r . p w m e x c h a n g e s t o h i g h s t a t u s . o n e c o m p l e t e c y c l e o f p w m . n e x t c y c l e .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 104 vers ion 1. 4 8.4.9 tc1 timer operati on explame ? tc1 timer configuration : ; reset tc1 timer. clr tc1m ; clear tc1 m register. ; set tc1 clock source and tc1 rate. mov a, #0 nnn 0 n 00b b0mov tc1 m, a ; set tc1 c and tc1 r register for tc1 interval time. mov a, # value ; tc1c m ust be equal to tc1r. b0mov tc1 c, a b0mov tc1 r, a ; clear tc1 irq b0bclr f tc1 irq ; enable tc1 timer and interrupt function. b0bset ftc1ien ; enable tc1 interrupt function. b0bset ftc1enb ; enable tc1 timer. p w m o u t p u t p w m 1 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 1 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( o u t p u t l o w ) . p w m 1 o u t = 1 . p w m 1 o u t = 0 . p w m o u t p u t p w m 1 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 1 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( o u t p u t h i g h ) . p w m 1 o u t = 1 . p w m 1 o u t = 0 . p w m o u t p u t p w m 1 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 1 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( i n p u t ) . p w m 1 o u t = 1 . p w m 1 o u t = 0 . h i g h i m p e n d e n c e ( f l o a t i n g )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 105 vers ion 1. 4 ? tc 1 event counter configuration : ; reset tc 1 timer. clr tc1m ; clear tc 1 m register. ; enable tc1 event counter . b0bset ftc1cks1 ; set tc1 clock source from external input pin (p0.1). ; set tc 1 c and tc 1 r register for tc 1 interval time. mov a, # value ; t c1c must be equal to tc1r. b0mov tc 1 c, a b0mov tc 1 r, a ; clear tc 1 irq b0bclr ftc 1 irq ; enable tc 1 timer and interrupt function. b0bset ftc1ien ; enable tc1 interrupt function. b0bset ftc1enb ; enable tc1 timer. ? tc1 pwm conf iguration : ; reset tc1 timer. clr tc1m ; clear tc1 m register. ; set tc1 clock source and tc1 rate. mov a, #0 nnn 0 n 00b b0mov tc1 m, a ; set tc1 c and tc1 r register for pwm cycle . mov a, # value 1 ; tc1c must be equal to tc1r. b0mov tc 1 c, a b0mov tc1 r, a ; set tc1 d register for pwm duty. mov a, # value 2 ; tc1d must be greater than tc1r. b0mov tc1 d , a ; enable pwm and tc1 timer . b0bset ftc1enb ; enable tc1 timer. b0bset fpwm1out ; enable pwm.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 106 vers ion 1. 4 8.5 tc2 8 - bit timer /counter 8.5.1 overview the tc 2 timer is an 8 - bit binary up timer with basic timer, event counter and pwm functions. the basic timer function supports flag indicator (tc2irq bit) and interrupt operation (interrupt vector). the interval time is programmable thro ugh tc2m, tc2c, tc2r registers. the event counter is changing tc 2 clock source from system clock (fcpu/fhosc) to external clock like signal (e.g. continuous pulse, r/c type oscillating signal ) . tc2 becomes a counter to count external clock number to imple ment measure application . tc2 also builds in duty/cycle programmable pwm. the pwm cycle and resolution are controlled by tc2 timer clock rate, tc2r and tc2d registers, so the pwm with good flexibility to implement ir carry signal, motor control and brightn ess adjuster the main purposes of the tc 2 timer are as following. ? 8 - bit programmable up counting timer: generate time - out at specific time intervals based on the selected clock frequency. ? interrupt function: t c2 timer function support s interrupt function . when t c2 timer occurs overflow, the t c2 irq actives and the system points program counter to interrupt vector to do interrupt sequence. ? event counter: the event counter function counts the external clock counts. ? duty/cycle programmable pwm : the pwm is d uty/cycle programmable controlled by tc 2 r and tc 2 d registers. ? green mode function: all tc 2 functions (timer, pwm, event counter, auto - reload) keep running in green mode and no wake - up function. t c 2 r a t e ( f c p u / 1 ~ f c p u / 1 2 8 ) p 0 . 2 ( s c h m i t t e r t r i g g e r ) t c 2 c k s 1 t c 2 e n b c p u m 0 , 1 t c 2 c 8 - b i t b i n a r y u p c o u n t i n g c o u n t e r t c 2 r r e l o a d d a t a b u f f e r s r t c 2 t i m e o u t p 5 . 3 g p i o p 5 . 3 p i n p w m p w m 2 o u t l o a d c o m p a r e t c 2 d d a t a b u f f e r u p c o u n t i n g r e l o a d v a l u e f c p u f h o s c t c 2 c k s 0
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 107 vers ion 1. 4 8.5.2 tc 2 timer operation tc 2 tim er is controlled by tc 2 enb bit. when tc 2 enb= 0 , tc2 timer stops. when tc2enb=1, tc 2 timer starts to count. before enabling tc2 timer, setup tc2 timer s configurations to select timer function modes, e.g. basic timer, interrupt function tc2c increases 1 by timer clock source. when tc2 overflow event occurs, tc2irq flag is set as 1 to indicate overflow and cleared by program. the overflow condition is tc2c count from full scale (0xff) to zero scale (0x00). in difference function modes, tc2c value relates t o operation. if tc2c value changing effects operation, the transition of operations would make timer function error. so tc2 builds in double buffer to avoid these situations happen. the double buffer concept is to flash tc2c during tc2 counting, to set the new value to tc2r (reload buffer), and the new value will be loaded from tc2r to tc2c after tc2 overflow occurrence automatically. in the next cycle, the tc2 timer runs under new conditions, and no any transitions occur. the auto - reload function is no any control interface and always actives as tc2 enables. if tc2 timer interrupt function is enabled (tc2ien=1), the system will execute interrupt procedure. the interrupt procedure is system program counter points to interrupt vector (org 000eh) and executes interrupt service routine after tc2 overflow occurrence. clear tc2irq by program is necessary in interrupt procedure. tc2 timer can works in normal mode, slow mode and green mode. but in green mode, tc2 keep counting, set tc2irq and outputs pwm, but can t wake - up system. tc2 provides different clock sources to implement different applications and configurations. tc 2 clock source includes fcpu (instruction cycle) , fhosc (high speed oscillator) and external input pin (p0. 2 ) contro lled by tc2cks[1:0] bits . tc 2 cks0 bit selects the clock source is from fcpu or fhosc. if tc 2 cks0=0, tc0 clock source is fcpu through tc 2 rate[2:0] pre - scal a r to decide fcpu/1~fcpu/128. if tc 2 cks0=1, tc 2 clock source is fhosc through tc 2 rate[2:0] pre - scal a r to decide fcpu/1~fcpu/128 . tc 2 cks1 bit controls the clock source is external input pin or controlled by tc 2 cks0 bit. if tc 2 cks1=0, tc 2 clock source is selected by tc 2 cks0 bit. if tc 2 cks1=1, tc 2 clock source is external input pin that means to enable event counter fu nction . tc2rate[2:0] pre - scalar is unless when tc2cks0=1 or tc2cks1=1 conditions. tc2 length is 8 - bit (256 steps), and the one count period is each cycle of input clock. tc2cks0 tc 2 rate[2:0] tc 2 clock tc 2 interval time fhosc=16mhz, fcpu=fh osc/ 4 fhosc=4mhz, fcpu=fhosc/4 max. (ms) unit (us) max. (ms) unit (us) 0 000b fcpu/ 128 8.192 32 32.768 128 0 001b fcpu/ 64 4.096 16 16.384 64 0 010b fcpu/ 32 2.048 8 8.192 32 0 011b fcpu/ 16 1.024 4 4.096 1 6 0 100b fcpu/ 8 0.512 2 2.048 8 0 101b fcp u/ 4 0.256 1 1.024 4 0 110b fcpu/ 2 0.128 0.5 0.512 2 0 111b fcpu/ 1 0.064 0.25 0. 256 1 1 000b fhosc /128 2.048 8 8.192 32 1 001b fhosc /64 1.024 4 4.096 16 1 010b fhosc /32 0.512 2 2.048 8 1 011b fhosc /16 0.256 1 1.024 4 1 100b fhosc /8 0.128 0.5 0.512 2 1 101b fhosc /4 0.064 0.25 0.256 1 1 110b fhosc /2 0.032 0.125 0.128 0.5 1 111b fhosc /1 0.016 0.0625 0.064 0.25 0 x 0 0 o r t c 2 r . . . . . . c l o c k s o u r c e t c 2 c t c 2 i r q t c 2 t i m e r o v e r f l o w s . t c 2 i r q s e t a s 1 . r e l o a d t c 2 c f r o m t c 2 r a u t o m a t i c a l l y . t c 2 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 1 0 x 0 2 0 x 0 3 0 x f e 0 x f f t c 2 r . . . . . .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 108 vers ion 1. 4 8.5.3 tc 2 m mode register tc 2 m is tc 2 timer mode control register to configure tc 2 operating mode including tc 2 pre - scal a r, clock source, pwm funct ion these configurations must be setup completely before enabling tc2 timer. 0bch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc 2 m tc 2 enb tc 2 rate2 tc 2 rate1 tc 2 rate0 tc 2 cks1 tc 2 cks0 - pwm 2 out read/write r/w r/w r/w r/w r/w r/w - r/w after reset 0 0 0 0 0 0 - 0 bit 0 pwm2out: pwm output control bit. 0 = disable pwm output function, and p5.3 is gpio mode. 1 = enable pwm output function, and p5.3 outputs pwm signal. bit 2 tc 2 cks0: tc 2 clock source select bit. 0 = fcpu. 1 = fhosc. bit 3 tc 2 c ks1: tc 2 clock source select bit. 0 = internal clock ( fcpu and fhosc controlled by tc 2 cks0 bit ) . 1 = external input pin (p0. 2 /int 2 ) and enable event counter function. tc 2 rate[2:0] bits are useless. bit [6:4] t c2 rate[2:0]: t c2 timer clock source select b its. t c2 cks0=0 - > 000 = fcpu/128, 001 = fcpu/64, 010 = fcpu/32, 011 = fcpu/16, 100 = fcpu/8, 101 = fcpu/4, 110 = fcpu/2,111 = fcpu/1. tc2 cks0=1 - > 000 = f hosc /128, 001 = f hosc /64, 010 = f hosc /32, 011 = f hosc /16, 100 = f hosc /8, 101 = f hosc /4, 110 = f hosc / 2,111 = f hosc /1. bit 7 t c2 enb: t c 0 counter control bit. 0 = d isable tc2 timer. 1 = enable tc2 timer . 8.5.4 tc 2 c counting register tc2c is tc2 8 - bit counter. when tc2c overflow occurs, the tc2irq flag is set as 1 and cleared by program. the tc2c decides tc2 interval time through below equation to calculate a correct value. it is necessary to write the correct value to tc2c register and tc2r register first time, and then enable tc2 timer to make sure the fist cycle correct. after one tc2 overflow occurs, the tc2c register is loaded a correct value from tc2r register automatically, not program. 0bdh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc 2 c tc 2 c7 tc 2 c6 tc 2 c5 tc 2 c4 tc 2 c3 tc 2 c2 tc 2 c1 tc 2 c0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t c2 c initial value is as following. t c2 c initial value = 256 - (t c2 interrupt interval time * tc2 clock rate )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 109 vers ion 1. 4 8.5.5 tc 2r auto - reload register tc2 timer builds in auto - reload function, and tc2r register stores reload data . when tc2c overflow occurs, tc2c register is loaded data from tc2r register automatically. under tc2 timer counting status, to modify tc2 interval time is to modify tc 2 r register, not tc 2 c register . n ew tc2c data of tc2 interval time will be updated after tc2 timer overflow occurrence, tc2r loads new value to tc2c register. but at the first time to setup tc2m, tc2c and tc2r must be set the same value before enabling tc2 timer. tc2 is double buffer design. if new tc2r value is set by program, the new value is stored in 1 st buffer. until tc2 overflow occurs, the new value moves to real tc2r buffer. this way can avoid any transitional condition to affect the correctness of tc2 interval time and pwm output signal. 0beh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc 2r tc 2r 7 tc 2r 6 tc 2r 5 tc 2r 4 tc 2r 3 tc 2r 2 tc 2r 1 tc 2r 0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the equation of t c2r initial value is as following. t c2r initial value = 256 - (t c2 interrupt interval time * tc2 clock rate ) ? ex ample: to calculation tc2c and tc2r value to obtain 10ms tc2 interval time. tc2 clock source is fcpu = 16mhz/16 = 1mhz. select tc0rate=000 (fcpu/128). tc 2 interval time = 10ms. tc 2 clock rate = 16 mhz/ 16 /128 tc2c/ t c2r initial value = 256 - (t c2 interval t ime * input clock) = 256 - (10ms * 16mhz / 16 / 128 ) = 256 - ( 10 - 2 * 16 * 10 6 / 16 / 128 ) = b2h 8.5.6 tc 2d pwm duty register tc2d register s purpose is to decide pwm duty. in pwm mode, tc2r controls pwm s cycle, and tc2d controls the duty of pwm. the operation is base on timer counter value. w h en tc2c = tc2d, the pwm high duty finished and exchange to low level. it is easy to configure tc2d to choose the right pwm s duty for application. 0 bf h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t c 2 d t c2d 7 t c2d 6 t c 2d 5 t c2d 4 t c2d 3 t c2d 2 t c2d 1 t c2d 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t c2d initial value is as following. t c2d initial value = tc2r + ( pwm high pulse width period / tc2 clock rate ) ? example: to c alculate tc2d value to obtain 1/3 duty pwm signal. the tc2 clock source is fcpu = 16mhz/16= 1mhz. select tc2rate=000 (fcpu/128). tc 2r = b2h . tc2 interval time = 10ms. so the pwm cycle is 100hz. in 1/3 duty condition, the high pulse width is about 3.33ms. tc2d initial value = b2h + ( pwm high pulse width period / t c2 clock rate ) = b2h + ( 3.33 ms * 16mhz / 16 / 128) = b2h + 1ah = cch
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 110 vers ion 1. 4 8.5.7 tc 2 ev ent counter tc 2 event counter is set the tc 2 clock source from external input pin (p0. 2 ). when tc 2 cks1=1, tc 2 clock sou rce is switch to external input pin (p0. 2 ). tc 2 event counter trigger direction is falling edge. when one falling edge occurs, tc 2 c will up one count. when tc 2 c counts from 0xff to 0x00, tc 2 triggers overflow event. the external event counter input pins w ake - up function of gpio mode is disabled when tc 2 event counter function enabled to avoid event counter signal trigger system wake - up and not keep in power saving mode. the external event counter input pins external interrupt function is also disabled whe n tc 2 event counter function enabled , and the p02irq bit keeps 0 status. the event counter usually is used to measure external continuous signal rate, e.g. continuous pulse, r/c type oscillating signal these signal phase don t synchronize with mcu s main clock. use tc2 event to measure it and calculate the signal rate in program for different applications. 8.5.8 pulse width modulation (pwm) the pwm is duty/cycle programmable design to offer various pwm signals. when tc2 timer ena bles and pwm2out bit sets as 1 (enable pwm output), the pwm output pin (p5.3) outputs pwm signal. one cycle of pwm signal is high pulse first, and then low pulse outputs. tc2r register controls the cycle of pwm, and tc2d decides the duty (high pulse widt h length) of pwm. tc2c initial value is tc2r reloaded when tc2 timer enables and tc2 timer overflows. when tc2c count is equal to tc2d, the pwm high pulse finishes and exchanges to low level. when tc2 overflows (tc2c counts from 0xff to 0x00), one complete pwm cycle finishes. the pwm exchanges to high level for next cycle. the pwm is auto - reload design to load tc2c from tc2r automatically when tc2 overflows and the end of pwm s cycle, to keeps pwm continuity. if modify the pwm cycle by program as pwm output ting , the new cycle occurs at next cycle when tc2c loaded from tc2r. the resolution of pwm is decided by tc2r. tc2r range is from 0x00~0xff. if tc2r = 0x00, pwm s resolution is 1/256. if tc2r = 0x80, pwm s resolution is 1/12 8. tc2d controls the high pulse width of pwm for pwm s duty. when tc2c = tc2d, pwm output exchanges to low status. tc2d must be greater than tc2r, or the pwm signal keeps low status. when pwm outputs, tc2irq still actives as tc2 overflows, and tc2 interrup t function actives as tc2ien = 1. but strongly recommend be careful to use pwm and tc2 timer together, and make sure both functions work well. the pwm output pin is shared with gpio and switch to output pwm signal as pwm2out=1 automatically. if pwm2out bi t is cleared to disable pwm, the output pin exchanges to last gpio mode automatically. it easily to implement carry signal on/off operation, not to control tc2enb bit. 0 x 0 0 o r t c 2 r . . . . . . e x t e r n a l i n p u t s i g n e l t c 2 c t c 2 i r q t c 2 t i m e r o v e r f l o w s . t c 2 i r q s e t a s 1 . r e l o a d t c 2 c f r o m t c 2 r a u t o m a t i c a l l y . t c 2 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 1 0 x 0 2 0 x 0 3 0 x f e 0 x f f t c 2 r . . . . . . t c 2 r t c 2 r + 1 t c 2 r + 2 t c 2 c . . . t c 2 d - 2 t c 2 d - 1 t c 2 d p w m o u t p u t . . . 0 x f d 0 x f e 0 x f f t c 2 r t c 2 r + 1 t c 2 r + 2 . . . e n a b l e t c 2 a n d p w m . t c 2 c i s l o a d e d f r o m t c 2 r . p w m o u t p u t s h i g h s t a t u s . t c 2 c = t c 2 d . p w m e x c h a n g e s t o l o w s t a t u s . t c 2 c o v e r f l o w s f r o m 0 x f f t o 0 x 0 0 . t c 2 c i s l o a d e d f r o m t c 2 r . p w m e x c h a n g e s t o h i g h s t a t u s . o n e c o m p l e t e c y c l e o f p w m . n e x t c y c l e .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 111 vers ion 1. 4 8.5.9 tc2 timer operation explame ? tc 2 timer configuration : ; reset tc 2 timer. clr tc2m ; clear tc 2 m register. ; set tc 2 clock source and tc 2 rate. mov a, #0 nnn 0 n 00b b0mov tc 2 m, a ; set tc 2 c and tc 2 r register for tc 2 interval time. mov a, # value ; tc2c must be equal to tc2r. b0mov tc 2 c, a b0mov tc 2 r, a ; clear tc 2 irq b0bclr ftc 2 irq ; enable tc 2 timer and interrupt function. b0bset ftc2ien ; enable tc2 interrupt function. b0bset ftc2enb ; enable tc2 timer. p w m o u t p u t p w m 2 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 2 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( o u t p u t l o w ) . p w m 2 o u t = 1 . p w m 2 o u t = 0 . p w m o u t p u t p w m 2 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 2 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( o u t p u t h i g h ) . p w m 2 o u t = 1 . p w m 2 o u t = 0 . p w m o u t p u t p w m 2 o u t = 1 . t h e p i n e x c h a n g e s t o o u t p u t m o d e a n d o u t p u t s p w m s i g n a l a u t o m a t i c a l l y . p w m 2 o u t = 0 . t h e p i n e x c h a n g e s t o l a s t g p i o m o d e ( i n p u t ) . p w m 2 o u t = 1 . p w m 2 o u t = 0 . h i g h i m p e n d e n c e ( f l o a t i n g )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 112 vers ion 1. 4 ? tc 2 event counter configuration : ; reset tc 2 timer. clr tc2m ; clear tc 2 m register. ; enable tc2 event counter . b0bset ftc2cks1 ; set tc2 clock source from external input pin (p0.2). ; set tc 2 c and tc 2 r register for tc 2 interval time. mov a, # value ; tc2c must be equal to tc2r. b0mov tc 2 c, a b0mov tc 2 r, a ; clear tc 2 irq b0bclr ftc 2 irq ; enable tc 2 timer and interrupt function. b0bset ftc2ien ; enable tc2 interrupt function. b0bset ftc2enb ; enable tc2timer. ? tc0 pwm configuration : ; reset tc 2 timer. clr tc2 m ; clear tc 2 m register. ; set tc 2 clock source and tc 2 rate. mov a, #0 nnn 0 n 00b b0mov tc 2 m, a ; set tc 2 c and tc 2 r register for pwm cycle . mov a, # value 1 ; tc2c must be equal to tc2r. b0mov tc 2 c, a b0mov tc 2 r, a ; set tc 2 d register for pwm duty. mov a, # value 2 ; tc2d must be greater than tc2r. b0mov tc 2d , a ; enable pwm and tc2 timer . b0bset ftc2enb ; enable tc2 timer. b0bset fpwm2out ; enable pwm.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 113 vers ion 1. 4 8.6 t1 16 - bit timer with captu re timer function 8.6.1 overview th e t1 timer is a 16 - bit binary up timer with basic timer and capture timer functions. the basic timer function supports flag indicator (t1irq bit) and interrupt operation (interrupt vector). the interval time is programmable through t1m, t1ch/t1cl 16 - bit co unter registers. the capture timer supports high pulse width measurement, low pulse width measurement, cycle measurement and continuous duration from p0.3. t1 becomes a timer meter to count external signal time parameters to implement measure application . the main purposes of the t1 timer are as following. ? 16 - bit programmable up counting timer: generate time - out at specific time intervals based on the selected clock frequency. ? 16 - bit measurement: measure the input signal pulse width and cycle depend on t he t1 clock time base to decide the capture timers resolution. the capture timer builds in programmable trigger edge selection to decide the start - stop trigger event. ? 16 - bit capture timer: the 16 - bit event counter to detect event source for accumulative capture timer function. the event counter is up counting design. ? interrupt function: t1 timer function and capture timer function support interrupt function. when t1 timer occurs overflow or capture timer stops counting, the t1irq actives and the system p oints program counter to interrupt vector to do interrupt sequence. ? green mode function: all t1 functions (timer, capture timer) keeps running in green mode, but no wake - up function. timer irq actives as any irq trigger occurrence, e.g. timer overflow 8.6.2 t1 timer operation t1 timer is controlled by t1 enb bit. when t1 enb= 0 , t1 timer stops. when t1enb=1, t1 timer starts to count. before enabling t1 timer, setup t1 timer s configurations to select timer function modes, e.g. basic t imer, interrupt function t1 16 - bit counter (t1ch, t1cl) increases 1 by timer clock source. when t1 overflow event occurs, t1irq flag is set as 1 to indicate overflow and cleared by program. the overflow condition is t1ch, t1cl count from full scale (0x ffff) to zero scale (0x0000). t1 doesn t build in double buffer, so load t1ch, t1cl by program when t1 timer overflows to fix the correct interval time. if t1 timer interrupt function is enabled (t1ien=1), the system will execute interrupt procedure. the i nterrupt procedure is system program counter points to interrupt vector (org 000fh) and executes interrupt service routine after t1 overflow occurrence. clear t1irq by program is necessary in interrupt procedure. t1 timer can works in normal mode, slow mod e and green mode. t 1 e n b c p u m 0 , 1 t 1 c h , t 1 c l 1 6 - b i t b i n a r y u p c o u n t i n g c o u n t e r t 1 i r q i n t e r r u p t f l a g ( t 1 t i m e r o v e r f l o w . ) ( c a p t u r e t i m e r s t o p ) c p t m d t 1 c h b u f f e r t 1 c l b u f f e r w r i t e t 1 c l r e g i s t e r r e a d t 1 c l r e g i s t e r c p t g [ 1 : 0 ] c p t e n p 0 . 3 c p t c h , c p t c l 1 6 - b i t e v e n t c o u n t e r , b i n a r y u p c o u n t i n g c o u n t e r 1 2 4 8 1 6 3 2 6 4 1 2 8 t 1 r a t e f c p u f h o s c t 1 c k s 0 1 1 0 1 1 0 0 t r i g g e r t 1 c h , t 1 c l t i m e r s t a r t t o c o u n t a n d s t o p c o u n t i n g . c p t s t a r t c p t c o u n t e r o v e r f l o w . 0 1 1 0 s t o p t 1 c o u n t i n g s t o p c p t c o u n t i n g c p t m d t 1 e n b 0 x 0 0 0 0 o r n b y p r o g r a m . . . . . . c l o c k s o u r c e t 1 c h , t 1 c l t 1 i r q t 1 t i m e r o v e r f l o w s . t 1 i r q s e t a s 1 . r e l o a d t 1 c h , t 1 c l b y p r o g r a m . t 1 i r q i s c l e a r e d b y p r o g r a m . 0 x 0 0 0 1 o r n + 1 0 x f f f e 0 x f f f f . . . . . . 0 x 0 0 0 0 o r n b y p r o g r a m 0 x 0 0 0 2 o r n + 2 0 x 0 0 0 2 o r n + 2
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 114 vers ion 1. 4 t1 provides different clock sources to implement different applications and configurations. t 1 clock source includes fcpu (instruction cycle) and fhosc (high speed oscillator) controlled by t1cks bit . t 1 cks bit selects the clock source is from fcpu or fhosc. if t 1 cks=0, t 1 clock source is fcpu through t 1 rate[2:0] pre - scal a r to decide fcpu/1~fcpu/128. if t 1 cks=1, t 1 clock source is fhosc through t 1 rate[2:0] pre - scal a r to decide fcpu/1~fcpu/128 . t1 length is 16 - bit (65536 steps), and the one count period is each cycle of input clock. t1cks t 1 rate[2:0] t 1 clock t 1 interval time fhosc=16mhz, fcpu=fhosc/ 4 fhosc=4mhz, fcpu=fhosc/4 max. (ms) unit (us) max. (ms) unit (us) 0 000b fcpu/128 2097.152 32 8388. 608 128 0 001b fcpu/64 1048.576 16 4194.304 64 0 010b fcpu/32 524.288 8 2097.152 32 0 011b fcpu/16 262.144 4 1048.576 16 0 100b fcpu/8 131.072 2 524.288 8 0 101b fcpu/4 65.536 1 262.144 4 0 110b fcpu/2 32.768 0.5 131.072 2 0 111b fcpu/1 16.384 0.25 65.536 1 1 000b fhosc/128 524.288 8 2097.152 32 1 001b fhosc/64 262.144 4 1048.576 16 1 010b fhosc/32 131.072 2 524.288 8 1 011b fhosc/16 65.536 1 262.144 4 1 100b fhosc/8 32.768 0.5 131.072 2 1 101b fhosc/4 16.384 0.25 65.536 1 1 110b fhosc/2 8.192 0.125 32.768 0.5 1 111b fhosc/1 4.096 0.0625 16.384 0.25 8.6.3 t1m mode register t1 m is t1 timer mode control register to configure t1 operating mode including t1 pre - scal a r, clock source, capture parameters these configurations must be setup completely befo re enabling t1 timer. 0c0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t1 m t1 enb t1 rate2 t1 rate1 t1 rate0 t1cks read/write r/w r/w r/w r/w r/w after reset 0 0 0 0 0 bit 7 t1enb: t1 counter control bit. 0 = d isable t1 timer. 1 = enable t1 timer . bit [6:4] t1 rate[2:0]: t1 timer clock source select bits. t1 cks =0 - > 000 = fcpu/128, 001 = fcpu/64, 010 = fcpu/32, 011 = fcpu/16, 100 = fcpu/8, 101 = fcpu/4, 110 = fcpu/2,111 = fcpu/1. t1cks = 1 - > 000 = f hosc /128, 001 = f hosc /64, 010 = f hosc /32 , 011 = f hosc /16, 100 = f hosc /8, 101 = f hosc /4, 110 = f hosc /2,111 = f hosc /1. bit 3 t1 cks: t1 clock source control bit . 0 = fcpu . 1 = fhosc .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 115 vers ion 1. 4 8.6.4 t1c h, t1cl 16 - bit counting register s t1 counter is 16 - bit counter combined with t1ch and t1cl registers. whe n t1 timer overflow occurs, the t1irq flag is set as 1 and cleared by program. the t1ch, t1cl decide t1 interval time through below equation to calculate a correct value. it is necessary to write the correct value to t1ch and t1cl registers, and then ena ble t1 timer to make sure the fist cycle correct. after one t1 overflow occurs, the t1ch and t1cl registers are loaded correct value s by program. 0c1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t1c l t1c l 7 t1c l 6 t1c l 5 t1c l 4 t1c l 3 t1c l 2 t1c l 1 t1c l 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0 c 2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t1ch t1ch 7 t1ch 6 t1ch 5 t1ch 4 t1ch 3 t1ch 2 t1ch 1 t1ch 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the t1 timer counter length is 16 - bit and points to t1ch and t1cl registers. the timer counter is double buffer design. the core bus is 8 - bit, so access 16 - bit data needs a latch flag to avoid the transient status affect the 16 - bit data mistake occurrence. under write mode, the write t 1ch is the latch control flag. under read mode, the read t1cl is the latch control flag. so, write t1 16 - bit counter is to write t 1 ch first, and then write t1cl. the 16 - bit data is written to 16 - bit counter buffer after execut ing writing t 1 cl. read t1 16 - bit counter is to read t 1 cl first, and then read t 1 ch. the 16 - bit data is dumped to t 1 ch, t 1 cl after executing reading t 1 c h . ? read t1 counter buffer sequence is to read t1cl first, and then read t1ch. ? write t1 counter buffer sequence is to write t1ch first, and then write t1cl. the equation of t1 16 - bit counter (t1ch, t1cl) initial value is as following. t1c h, t1cl initial value = 65536 - (t1 interrupt interval time * t1 clock rate ) ? example: to calculation t1ch and t 1cl values to obtain 500 ms t1 interval time. t1 clock source is fcpu = 16mhz/16 = 1mhz. select t1rate=000 (fcpu/128). t1 interval time = 500 ms. t1 clock rate = 16mhz/16/128 t1 16 - bit counter initial value = 65536 - (t1 interval time * input clock) = 6553 6 - ( 50 0ms * 16mhz / 16 / 128 ) = 65536 - ( 500*10 - 3 * 16 * 10 6 / 16 / 128 ) = f0bdh (t1ch = f0 h, t1cl = bd h)
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 116 vers ion 1. 4 8.6.5 t1 cpature timer the 16 - bit capture timer is controlled by cpten bit, but the t1 must be enabled. set t1enb=1 and cpten=1 to enable capture timer function. the capture timer is a pure counter and no clock source to decide interval time. capture timer input source is p0.3 pin. cptg[1:0] bits select capture timer functions. ? cptg[1:0] = 00: capture timer function. ? cptg[1:0] = 01: measure p0.3 high pulse width. ? cptg[1:0] = 10: measure p0.3 low pulse width. ? cptg[1:0] = 11: measure p0.3 cycle. these functions must be combined t1 timer function to implement. the capture timer can measure high pulse width, low pulse width, cycle and capture duration of input signal (p0.3) controlled by cptg[1:0]. cptstart bit is to execute capture timer function. when cptstart is set as 1, the capture timer waits the right trigger edge to active 16 - bit counter. the trigger edge finds, and the 16 - bit counter starts t o count which clock source is t1. when the second right edge finds, the 16 - counter stops, cptstart is cleared and the t1irq actives. 8.6.5.1 capture timer the capture timer function controlled by cptg[1:0] bits. set cptg[1:0] = 00 to enable capture timer functio n. the capture timer functions purpose is to measure the period of a continuous signal. the function includes two modes for difference speed signal controlled by cptmd bit. to start capture timer operation is set cptstart bit as 1, and the trigger sourc e is the first rising edge of the p0.3 input signal. before the first rising edge, the capture timer and t1 timer keeps ideal status and wait the riding edge event. when catch the first edge, the capture timer and t1 timer start to count. each of overflow event occurs (controlled by cptmd bit), the capture timer and t1 timer stop counting, cptstart bit is cleared, and t1irq is set as 1. if t1ien = 1, the system executes t1 interrupt function and service routine. ? capture timer counting trigger source is the rising edge of input signal. ? cptmd = 0, low - speed mode ( t1enb = 1. cpten = 1. cptg[1:0] = 0 0 . ) input signal rate < t1 timer rate. use t1 timer to measure input signal continuous duration. set capture timer initial value (cptch, cptcl = m) an d clear t1 counter (t1ch, t1cl = 0x0000) by program. set cptsatrt bit (1) to start capture timer counting. capture timer and t1 start counting at the first rising edge of input signal. when capture timer overflow occurs (0xffff to 0x0000), t1 stops count ing, cptstart is cleared (0) automatically, and the t1irq sets as 1. the t1 16 - bit counter value (t1ch, t1cl = n) is the continuous signals duration. n + 1 n n + 2 n + 3 n + 4 n + 5 i n p u t s i g n a l 1 6 - b i t c a p t u r e t i m e r
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 117 vers ion 1. 4 ? cptmd = 1, high - speed mode ( t1enb = 1. cpten = 1. cptg[1:0] = 0 0 . ) input signal rate > t1 time r rate. set a unique timer by t1 timer to measure input signal counts. set t1 timer initial value (t1ch, t1cl = m) and clear capture timer counter (cptch, cptcl = 0x0000) by program. set cptsatrt bit (1) to start capture timer counting. capture timer a nd t1 start counting at the first rising edge of input signal. when t1 timer overflow occurs (0xffff to 0x0000), capture timer stops counting, cptstart is cleared (0) automatically, and the t1irq sets as 1. the capture timer 16 - bit counter value (cptch , cptcl = n) is the continuous signals counts. 8.6.5.2 high pulse width measurement t1enb = 1. cpten = 1. cptg[1:0] = 01 . the high pulse width measurement is using rising edge to trigger t1 timer counting and falling edge to stop t1 timer . if set cptstart bit at high pulse duration, the capture timer will measure next high pulse until the rising edge occurrence. when the end of measuring high pulse width and t1 timer stops, the t1irq sets as 1 , the t1 interrupt executes as t1ien =1, and t1ch, t1cl 16 - bit counter stores the period of high pulse width. 8.6.5.3 low pulse width measurement t1enb = 1. cpten = 1. cptg[1:0] = 10. the low pulse width measurement is using falling edge to start t1 timer counting and rising edge to stop t1 timer . if set cptstart bit at low pulse duration, the capture timer will measure next low pulse until the falling edge occurrence. when the end of measuring low pulse width and t1 timer stops, the t1irq sets as 1 , the t1 interrupt executes as t1ien=1, and t1ch, t1cl 16 - bit counter stores the period of low pulse width. i n p u t s i g n a l t 1 1 6 - b i t c o u n t e r ( t 1 c h , t 1 c l ) u n - k n o w d a t a 0 x ? ? ? ? 0 x 0 0 0 0 i n i t i a l i z a t i o n 1 2 n - 1 0 x 0 0 0 0 i n i t i a l i z a t i o n n 1 c p t s t a r t = 1 r i s i n g e d g e t 1 s t a r t s t o c o u n t . t 1 i s c o u n t i n g . f a l l i n g e d g e t 1 s t o p s c o u n t i n g . c p t s t a r t = 0 n i s t h e h i g h p u l s e w i d t h p e r i o d . r e a d i t b y p r o g r a m t h r o u g h t 1 c h , t 1 c l r e g i s t e r s . i n p u t s i g n a l u n - k n o w d a t a 0 x ? ? ? ? 0 x 0 0 0 0 i n i t i a l i z a t i o n 1 2 n - 1 0 x 0 0 0 0 i n i t i a l i z a t i o n n 1 c p t s t a r t = 1 f a l l i n g e d g e t 1 s t a r t s t o c o u n t . t 1 i s c o u n t i n g . r i s i n g e d g e t 1 s t o p s c o u n t i n g . c p t s t a r t = 0 n i s t h e l o w p u l s e w i d t h p e r i o d . r e a d i t b y p r o g r a m t h r o u g h t 1 c h , t 1 c l r e g i s t e r s . t 1 1 6 - b i t c o u n t e r ( t 1 c h , t 1 c l )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 118 vers ion 1. 4 8.6.5.4 input cycle measurement t1enb = 1. cpten = 1. cptg[1:0] = 11. the cycle measurement is using rising edge to start and stop t1 time r . if set cptstart bit at high or low pulse duration, the capture timer will measure next cycle until the rising edge occurrence. when the end of measuring cycle and t1 timer stops, the t1irq sets as 1 , the t1 interrupt executes as t1ien=1, and t1ch, t1c l 16 - bit counter stores the period of input cycle. 8.6.6 capture timer control registers c3h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 cptm cpten cptmd cptstart cptg1 cptg0 read/write r/w r/w r/w r/w r/w after reset 0 0 0 0 0 bit 7 cpten: capture timer function control bit. 0 = disable. 1 = enable. t1en must be enabled. bit 3 cptmd: capture timer mode control bit. 0 = cpt overflow mode. 1 = t1 overflow mode. bit 2 cptstart: capture timer counter control bit. 0 = process end. 1 = start to count and processing. bit [1:0] cptg[1:0]: capture timer function control bit. 00 = capture timer function. 01 = high pulse width measurement. 10 = low pulse width measurement. 11 = cycle measurement. i n p u t s i g n a l u n - k n o w d a t a 0 x ? ? ? ? 0 x 0 0 0 0 i n i t i a l i z a t i o n 1 2 n - 1 0 x 0 0 0 0 i n i t i a l i z a t i o n n 1 c p t s t a r t = 1 r i s i n g e d g e t 1 s t a r t s t o c o u n t . t 1 i s c o u n t i n g . r i s i n g e d g e t 1 s t o p s c o u n t i n g . c p t s t a r t = 0 n i s t h e c y c l e o f i n p u t s i g n a l . r e a d i t b y p r o g r a m t h r o u g h t 1 c h , t 1 c l r e g i s t e r s . t 1 1 6 - b i t c o u n t e r ( t 1 c h , t 1 c l )
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 119 vers ion 1. 4 c4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bi t 0 cptcl cptc7 cptc6 cptc5 cptc4 cptc3 cptc2 cptc1 cptc0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 c5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 cptch cptc15 cptc14 cptc13 cptc12 cptc11 cptc10 cptc9 cptc8 read/wri te r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the capture timer counter length is 16 - bit and points to cptch and cptcl registers. the timer counter is double buffer design. the core bus is 8 - bit, so access 16 - bit data needs a latch flag to avoid the transient status affect the 16 - bit data mistake occurrence. under write mode, the write cptcl is the latch control flag. under read mode, the read cptcl is the latch control flag. so, write 16 - bit counter is to write cptch first, and then wri te cptcl. the 16 - bit data is written to 16 - bit counter buffer after executing writing cptcl. read 16 - bit counter is to read cptcl first, and then read cptch. the 16 - bit data is dumped to cptch, cptcl after executing reading cptcl. ? read capture timer coun ter buffer sequence is to read cptcl first, and then read cptch. ? write capture timer counter buffer sequence is to write cptch first, and then write cptcl. 8.6.7 t1 timer operation explame ? t1 timer configuration : ; reset t1 timer. mov a, #0x00 ; clear t1 m register. b0mov t1 m, a ; set t1 clock rate. mov a, #0 nnn 0 0 00b ; t1rate[2:0] bits. b0mov t1 m, a ; set t1 ch, t1cl register s for t1 interval time. mov a, # value 1 ; set high byte first. b0mov t1 c h , a mov a, # value 2 ; set low byte . b0mov t1 c l , a ; clear t1 irq b0bclr f t1 irq ; enable t1 timer and interrupt function. b0bset ft1ien ; enable t1 interrupt function. b0bset ft1enb ; enable t1 timer.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 120 vers ion 1. 4 ? t1 capture timer for continuous signal measurement configurat ion : ; reset t1 timer. clr t1m ; clear t1 m register. ; set t1 clock rate and select/enable t1 capture timer . mov a, #0 nnn m 0 0 0 b ; nnn is t1rate[2:0] for t1 clock rate selection. b0mov t1 m, a ; m is t1 clock source control bit. mov a, #0 000 0 0 mm b ; mm is cptg[1:0] for t1 capture timer function selection. b0mov cptm , a ; cptg[1:0] = 00b, enable t1 capture timer. ; cptg[1:0] = 01b/10b/11b, enable pulse width or cycle measurement. ; select capture timer high - speed/low - speed mode . b0bclr fcptmd ; cpt overflow mode. ; or b0bset fcptmd ; t1 overflow mode. ; clear t1ch, t1cl . clr t1ch ; clear high byte first. clr t1cl ; clear low byte. ; set cpt ch, cpt cl 1 6 - bit capture timer for continuous signal measurement . mov a, # value 1 ; set high nibble first. b0mov cpt c h , a mov a, # value 2 ; set low byte. b0mov cpt c l , a ; clear t1 irq b0bclr f t1 irq ; enable t1 timer , interrupt function and t1 capture timer function. b0bset ft1ien ; enable t1 interrupt function. b0bset ft1enb ; enable t1 timer. b0bset fcpten ; enable t1 capture function. ; set capture timer start bit. b0bset fcptstart
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 121 vers ion 1. 4 ? t1 capture timer for single cycle measurement configuration : ; reset t1 timer. mov a, # 0x00 ; clear t1 m register. b0mov t1 m, a ; set t1 clock rate , select input source, and select/enable t1 capture timer . mov a, #0 nnn m 0 0 0 b ; nnn is t1rate[2:0] for t1 clock rate selection. b0mov t1 m, a ; m is t1 clock source control bit. mov a, #0 000 0 0 mm b ; mm is cptg[1:0] for t1 capture timer function selection. b0mov cptm , a ; cptg[1:0] = 00b, capture timer function. ; cptg[1:0] = 01b, high pulse width measurement. ; cptg[1:0] = 10b, low pulse width measurement. ; cptg[1 :0] = 11b, cycle measurement. ; clear t1ch, t1cl . clr t1ch ; clear high byte first. clr t1cl ; clear low byte. ; clear t1 irq b0bclr f t1 irq ; enable t1 timer , interrupt function and t1 capture timer function. b0bset ft1ien ; en able t1 interrupt function. b0bset ft1enb ; enable t1 timer. b0bset fcpten ; enable t1 capture function. ; set capture timer start bit. b0bset fcptstart
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 122 vers ion 1. 4 9 9 9 12 channel analog to digital converter (adc) 9.1 overview the analog to digital converter ( adc ) is sar structure with 12 - input sources and up to 1024 - step resolution to transfer analog signal into 1 0 - bits digital buffers . the adc builds in 12 - channel input source (ain0~ain11) to measure 12 different analog signal sources controlled by chs[3:0] and gchs bits. the adc resolution can be selected 8 - bit and 1 0 - bit resolutions through adlen bit. the adc converting rate can be selected by adcks[1:0] bits to decide adc converting time. the adc reference high voltage is avrefh pin . it is necessary to set p4 , p5 as input mode with out pull - up resistor by program. after setup adenb and ads bits, the adc start s to convert analog signal to digital data . when the conversion is complete, the adc circuit will set eoc and adcirq bit s to 1 and the digital data output s in adb and adr register s . if the adcien = 1, the adc interrupt request occurs and executes interrupt service routine when adcirq = 1 after adc converting. if adc interrupt function is enabled (adcien=1), the system will execute interrupt procedure. the i nterrupt procedure is system program counter points to interrupt vector (org 0010h) and executes interrupt service routine after finishing adc converting. clear adcirq by program is necessary in interrupt procedure. p 4 . 5 p 4 . 4 p 4 . 7 p 4 . 6 p 4 . 3 p 4 . 2 p 4 . 1 p 4 . 0 s a r a d c e n g i n e p 4 c o n p 5 c o n c h s [ 3 : 0 ] g c h s a d c h i g h r e f e r e n c e v o l t a g e a n a l o g i n p u t a d e n b a d s a d c c l o c k c o u n t e r a d c k s [ 1 : 0 ] a d l e n a d b [ 9 : 0 ] e o c a d c i r q 8 / 1 0 a d t [ 4 : 0 ] , a d t s [ 1 : 0 ] a d c o f f s e t c a l i b r a t i o n a v r e f h p 5 . 3 p 5 . 2 p 5 . 1 p 5 . 0
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 123 vers ion 1. 4 9.2 ad c mode register ad m is adc mode control register to configure adc configurations including adc start, adc channel selection, adc high reference voltage source and adc processing indicator these configurations must be setup completely before starting adc conv erting. 0c8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adm adenb ads eoc gchs chs 3 chs2 chs1 chs0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 adenb: adc control bit. in power saving mode, disable adc to reduce power consumption. 0 = disable adc function. 1 = enable adc function. bit 6 ads: adc start control bit. ads bit is cleared after adc processing automatically. 0 = adc converting stops. 1 = start to execute adc converting. bit 5 eoc: adc status bit . eo c bit must be cleared by program before adc start . 0 = adc progressing. 1 = end of converting and reset ads bit. bit 4 gchs: adc global channel select bit. 0 = disable ain channel . 1 = enable ain channel . bit [ 3 :0] chs[ 3 :0]: adc input channel se lect bit. 0000 = ain0, 0001 = ain1, 0010 = ain2, 0011 = ain3, 0100 = ain4, 0101 = ain5, 0110 = ain6, 0111 = ain7 , 1000 = ain8, 1001 = ain9, 1010 = ain10, 1011 = ain11, 1100 ~ 1111= reserved. adr register includes adc mode control and adc low - nibble data buffer. adc configurations including adc clock rate and adc resolution. these configurations must be setup completely before starting adc converting. 0cah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adr - adcks1 adlen adcks0 - - adb1 adb0 read/wri te - r/w r/w r/w - - r r after reset - 0 0 0 - - - - bit 6,4 adcks [1:0] : adcs clock rate select bit. 00 = fcpu/16 , 01 = fcpu/8 , 10 = fcpu/1, 11 = fcpu/2 bit 5 adlen: adcs resolution select bits. 0 = 8 - bit . 1 = 1 0 - bit.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 124 vers ion 1. 4 9.3 adc data buffer regist ers adc data buffer is 10 - bit length to store adc converter result. the high byte is adb register, and the low - nibble is adr[1:0] bits. the adb register is only 8 - bit register including bit2~bit9 adc data. to combine adb register and the low - nibble of adr will get full 10 - bit adc data buffer. the adc data buffer is a read - only register and the initial status is unknown after system reset. ? adb[9:2]: in 8 - bit adc mode, the adc data is stored in adb register. ? adb[9:0]: in 1 0 - bit adc mode, the adc data is st ored in adb and adr registers. 0c9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adb adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 read/write r r r r r r r r after reset - - - - - - - - bit[7:0] adb[7:0]: 8 - bit adc data buffer and the high - byte data buf fer of 10 - bit adc. 0cah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adr - adcks1 adlen adcks0 adb1 adb0 read/write - r/w r/w r/w r r after reset - 0 0 0 - - bit [3:0] adb [3:0]: 12 - bit low - nibble adc data buffer. the ain input voltage v. s. adb output data ain n adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 adb1 adb0 0/ 1024 *vrefh 0 0 0 0 0 0 0 0 0 0 1/ 1024 *vrefh 0 0 0 0 0 0 0 0 0 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1022 / 1024 *vrefh 1 1 1 1 1 1 1 1 1 0 1023 / 1 024 *vrefh 1 1 1 1 1 1 1 1 1 1 for different applications, users maybe need more than 8 - bit resolution but less than 10 - bit. to process the adb and adr data can make the job well. first, the adc resolution must be set 10 - bit mode and then to execute adc c onverter routine. then delete the lsb of adc data and get the new resolution result. the table is as following. adc resolution adb adr adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 adb1 adb0 8 - bit o o o o o o o o x x 9 - bit o o o o o o o o o x 10 - bit o o o o o o o o o o ? note : the initial status of adc data buffer including adb register and adr low - nibble after the system reset is unknown .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 125 vers ion 1. 4 9.4 adc operation descri ption and notic 9.4.1 adc signal format adc sampling voltage range is limited by high/low referen ce voltage. the adc low reference voltage is vss and not changeable . the adc high reference voltage is avrefh pin. adc reference voltage range limitation is ( adc high reference voltage C low reference voltage) R . adc low reference voltage is vss = 0v. so adc high reference voltage range is 2v~vdd . the range is adc external high reference voltage range. ? adc internal low reference voltage = 0v. ? adc external high reference voltage = 2v~vdd. adc sampled input signal voltage must be from adc low refere nce voltage to adc high reference. if the adc input signal voltage is over the range, the adc converting result is error (full scale or zero). ? adc low reference voltage Q Q 9.4.2 adc convert ing time the adc converting time is from ads=1 (start to adc convert) to eoc=1 (end of adc convert). the converting time duration is depend on adc resolution and adc clock rate. 10 - bit adc s convertin g ti me is 1/(adc clock /4)*1 4 sec , and the 8 - bit adc converting time is 1/(adc clock /4)*1 2 sec. adc clock source is fcpu and includes fcpu/1, fcpu/2, fcpu/8 and fcpu/16 controlled by adcks[1:0] bits. the adc convert ing time affects adc performance. if input high rate analog signal, it is necessary to select a high adc converting rate. if the adc converting time is slower than analog signal variation rate, the adc result would be error. so to select a correct adc cloc k rate and adc resolution to decide a right adc converting rate is very important. 10 - bit adc conversion time = 1/(adc clock rate /4)*1 4 sec adlen adcks1 , adcks0 adc clock rate fcpu=4mhz fcpu=16mhz adc converting time adc converting rate adc con verting time adc converting rate 1 ( 1 0 - bit) 0 0 fcpu/ 16 1/(4mhz/ 1 6 /4 )*1 4 = 2 24 us 4.464khz 1/( 16 mhz/ 1 6 /4 )*1 4 = 56 us 17.857khz 0 1 fcpu/8 1/(4mhz/8 /4 )*1 4 = 1 12 us 8.929khz 1/( 16 mhz/8 /4 )*1 4 = 28 us 35.71khz 1 0 fcpu 1/ ( 4mhz /4) *1 4 = 14 us 71.43khz 1/ ( 1 6 mhz /4) *1 4 = 3.5 us 286khz 1 1 fcpu/2 1/(4mhz/2 /4 )*1 4 = 28 us 35.71khz 1/( 16 mhz/2 /4 )*1 4 = 7 us 143khz 8 - bit adc conversion time = 1/(adc clock rate /4)*12 sec adlen adcks1 , adcks0 adc clock rate fcpu=4mhz fcpu=16mhz adc converting time adc converting rate adc converting time adc converting rate 0 ( 8 - bit) 0 0 fcpu/ 16 1/(4mhz/ 1 6 /4 )*12 = 192 us 5.208khz 1/( 16 mhz/ 1 6 /4 )*1 2 = 48 us 20.833khz 0 1 fcpu/8 1/(4mhz/8 /4 )*12 = 96 us 10.416khz 1/( 16 mhz/8 /4 )*1 2 = 24 us 41.667khz 1 0 fcpu 1/ ( 4mhz /4) *1 2 = 12 us 83.333khz 1/ ( 16 mhz /4) *1 2 = 3 us 333.333khz 1 1 fcpu/2 1/(4mhz/2 /4 )*12 = 24 us 41.667khz 1/( 16 mhz/2 /4 )*1 2 = 6 us 166.667khz
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 126 vers ion 1. 4 9.4.3 adc pin configuration adc input channels are shared with port4 and port5. adc channel selection is through adchs[3 :0] bit. adchs[3:0] value points to the adc input channel directly. adchs[3 :0]=000 0 selects ain0. adchs[3 :0]=00 01 selects ain 1 only one pin of port4 and port5 can be configured as adc input in the same time. the pins of port4 and port5 configured as adc i nput channel must be set input mode, disable internal pull - up and enable p4con and p5con first by program. after selecting adc input channel through adchs[3:0], set gchs bit as 1 to enable adc channel function. ? the gpio mode of adc input channels must be set as input mode. ? the internal pull - up resistor of adc input channels must be disabled. ? p4con and p5con bits of adc input channel must be set . adc input pins are shared with digital i/o pins. connect an analog signal to coms digital input pin, espe cially, the analog signal level is about 1/2 vdd will cause extra current leakage. in the power down mode, the above leakage current will be a big problem. unfortunate ly, if users connect more than one analog input signal to port4 or port5 will encounter a bove current leakage situation. p4con /p5con is port4 /port5 c onfiguration register. write 1 into p4con [7:0] and p5con [3:0] will configure related port4/port5 pin will be set as input mode and disable pull - up resistor. 0c6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4con p4con7 p4con6 p4con5 p4con4 p4con3 p4con2 p4con1 p4con0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit[7:0] p4con[7:0]: p4.n configuration control bits. 0 = p4.n can be a digital i/o pin . 1 = p4.n will be set as input mode and disable pull - up resistor. 0c7h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5con p5con3 p5con2 p5con1 p5con0 read/write r/w r/w r/w r/w after reset 0 0 0 0 bit[3:0] p5con[3:0]: p5.n configuration co ntrol bits. 0 = p 5 .n can be a digital i/o pin. 1 = p 5 .n will be set as input mode and disable pull - up resistor.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 127 vers ion 1. 4 9.4.4 adc operation examlpe ? adc configuration : ; reset adc . clr adm ; clear tc0m register. ; set adc clock rate and adc resolution . mov a, #0 n m n 00 0 0b ; nn: adcks[1:0] for adc clock rate. b0mov adr , a ; m: adlen for adc reolution. ; set adc input channel configuration . mov a, # value 1 ; set p4con for adc input channel. b0mov p4con , a mov a, # value 2 ; set adc in put channel as input mode. b0mov p4m , a mov a, # value 3 ; disable adc input channel s internal pull - up resistor. b0mov p4ur , a ; enable adc. b0b set f ad enb ; execute adc 100us warm - up time delay loop. call 100usdly ; 100us delay lo op. ; select adc input channel. mov a, # value ; set adchs[3:0] for adc input channel selection. or adm, a ; enable adc input channel. b0bset fgchs ; enable adc interrupt function. b0bclr fadcirq ; clear adc interrupt flag. b0bset fadcien ; enable adc interrupt function. ; start to execute adc converting . b0bset fads ? note: 1. when adenb is enabled, the system must be delay 100us to be the adc warm - up time by program, and then set ads to do adc converting. the 100us delay time is necessary after adenb setting (not ads setting), or the adc converting result would be error. normally, the adenb is set one time when the system under normal run condition, and do the delay time only one time. 2. in power saving situation lik e power down mode and green mode, and not using adc function, to disable adc by program is necessary to reduce power consumption.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 128 vers ion 1. 4 ? adc converting operation : ; adc interrupt disable mode . @@: b0bts1 feoc ; check adc processing flag. jmp @b ; e oc=0: adc is processing. b0mov a, adb ; eoc=1: end of adc processing . process adc result. b0mov buf1,a mov a, #00000011b and a, adr b0mov buf2,a ; end of processing adc result. clr feoc ; clear adc processing flag for next adc convert ing. ; adc interrupt enable mode . org 8 ; interrupt vector. int_sr: ; interrupt service routine. b0bts1 fadcirq ; check adc interrupt flag. jmp exit_int ; adcirq =0: not adc interrupt request . b0mov a, adb ; adcirq=1: end of adc proce ssing . process adc result. b0mov buf1,a mov a, #00000011b and a, adr b0mov buf2,a ? note: ads is cleared when the end of adc converting automatically. eoc bit indicates adc processing status immediately and is cleared when ads = 1. users needn t to clear it by program.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 129 vers ion 1. 4 9.5 adc application circ uit the analog signal is inputted to adc input pin ainn/p4.n . the adc input signal must be through a 0.1uf capacitor a . the 0.1uf capacitor is set between adc input pin and vss pin, and must be on the side of the adc input pin as possibl e. don t connect the capacitor s ground pin to ground plain directly, and must be through vss pin. the capacitor can reduce the power noise effective coupled with the analog signal. the external high reference source (avrefh) must be through a 47uf c c apacitor first, and then 0.1uf capacitor b . these capacitors are set between avrefh pin and vss pin, and must be on the side of the avrefh pin as possible. don t connect the capacitor s ground pin to ground plain directly, and must be through vss pin. v c c g n d 0 . 1 u f a n a l o g s i g n a l i n p u t 4 7 u f 0 . 1 u f e x t e r n a l h i g h r e f e r e n c e v o l t a g e m a i n p o w e r t r u n k a i n n / p 4 . n v s s a v r e f h m c u a b c
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 130 vers ion 1. 4 1 1 1 0 0 0 universal asynchronous receiver/transmitter (uart) 10.1 overview the uart interface is an universal asynchronous receiver/transmitter method. the serial interface is applied to low speed data transfer and communicate with low speed peripheral devices. the ua rt transceiver of sonix 8 - bit mcu allows rs232 standard and supports one byte data length. the transfer format has start bit, 8 - bit data, parity bit and stop bit. programmable baud rate supports different speed peripheral devices. uart i/o pins support pus h - pull and open - drain structures controlled by register. the uart features include the following: ? full - duplex, 2 - wire asynchronous data transfer. ? programmable baud rate. ? 8 - bit data length. ? odd and even parity bit. ? end - of - transfer interrupt. ? suppo rt dmx512 protocol. ? support break pocket function . ? support wide range baud rate. uart interface structure diagram f h o s c u a r t b a u d r a t e c o n t r o l b l o c k ( p r e - s c a l e r a n d d i v i d e r ) u r r x d 1 8 - b i t b u f f e r u r x u r x e n c p u m 1 , 0 u a r t i / o c o u n t e r p a r i t y c h e c k u r r x d 2 8 - b i t b u f f e r u r x m u r x p s u r x p e n u r x s 1 , 0 a n d r x i n t e r r u p t t x i n t e r r u p t u r x e n u r x p c u r t x d 1 8 - b i t b u f f e r u t x u t x e n c p u m 1 , 0 p a r i t y c h e c k u r t x d 2 8 - b i t b u f f e r u t x m u t x p s u t x p e n u t x p c u t x e n
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 131 vers ion 1. 4 10.2 uart operation the uart rx and tx pins are shared with gpio. when uart enables ( u rxen=1, u txen=1), the uart shared pins transfers to uart purpose and disable gpio function automatically. when uart disables, the uart pins returns to gpio last status. the uart data buffer length supports 1 - byte. the uart supports interrupt function . urxien/utxien are uart trans fer interrupt function control bit. urxien=0, disable uart receiver interrupt function . utxien=0, disable uart transmitter interrupt function . urxien=1, enable uart receiver interrupt function . utxien=1, enable uart transmitter interrupt functio n. when uar t interrupt function enable, the program counter points to interrupt vector (org 0013h/0014h) to do uart interrupt service routine after uart operating. urxirq/utxirq is uart interrupt request flag, and also to be the uart operating status indicator when u rxien=0 or utxien=0, but cleared by program. when uart operation finished, the urxirq/utxirq would be set to 1 . the uart also builds in busy bit to indicate uart bus status. urxbz bit is uart rx operation indicator. utxbz bit is uart tx operation ind icator. if bus is transmitting, the busy bit is 1 status. if bus is finishing operation or in idle status, the busy bit is 0 status. uart tx operation is controlled by loading utxd data buffer. after uart tx configuration, load transmitted data into utxd 8 - bit buffer, and then uart starts to transmit the pocket following uart tx configuration. uart rx operation is controlled by receiving the start bit from master terminal. after uart rx configuration, urx pin detects the falling edge of start bit, a nd then uart starts to receive the pocket from master terminal. uart provides urxpc bit and ufmer bit to check received pocket. urxpc bit is received parity bit checker. if received parity is error, urxpc sets as 1 . if urxpc bit is zero after receiving pocket, the parity is correct. ufmer bit is received stream frame checker. the stream frame error definition includes start bit error , stop bit error , stream length error , uart baud rate error ... each of frame error conditions makes ufmer bit sets as 1 after receiving pocket.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 132 vers ion 1. 4 10.3 uart baud rate uart clock is 2 - stage structure including a pre - scaler and an 8 - bit buffer . uart clock source is generated from system oscillator called fhosc. fhosc passes through uart pre - scaler to get uart main clock c alled fuart. uart pre - scaler has 8 selections (fhosc/1, fhosc/2, fhosc/4, fhosc/8, fhosc/16, fhosc/32, fhosc/64, fhosc/128) and 3 - bit control bits (urs[2:0]) . uart main clock (fuart) purposes are the front - end clock and through uart 8 - bit buffer (urcr) to obtain uart processing clock and decide uart baud rate . uart pre - scaler selection, urs[2:0] uart main clock rate fuart (fhosc=16mhz) 000b fhosc/1 16mhz 001b fhosc/2 8mhz 010b fhosc/4 4mhz 011b fhosc/8 2mhz 100b fhosc/16 1mhz 101b fhosc/32 0.5mhz 1 10b fhosc/64 0.25mhz 111b fhosc/128 0.125mhz 0e6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urcr urcr7 urcr6 urcr5 urcr4 urcr3 urcr2 urcr1 urcr 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the uart baud rate clock s ource is fhosc and divided by pre - scalar. the equation is as following. uart b aud rate = 1/2 *(fuart * 1/(256 - urcr)) bps fhosc = 16mhz baud rate uart pre - scaler urs[2:0] urcr (hex) accuracy (%) 1200 fhosc/ 32 101 b 30 - 0.16% 2400 fhosc/ 32 10 1 b 98 - 0.16% 4800 fhosc/ 32 101 b cc - 0.16% 9600 fhosc/ 32 101 b e6 - 0.16% 19200 fhosc/ 32 101 b f3 - 0.16% 38400 fhosc/1 000b 30 - 0.16% 51200 fhosc/1 000b 64 - 0.16% 57600 fhosc/1 000b 75 0.08% 102400 fhosc/1 000b b2 - 0.16% 115200 fhosc/1 000b bb - 0.64% 128000 fhosc/1 000b c1 0.80% 250000 fhosc/1 000b e0 0.00% ? note: 1. we strongly recommend not to set urcr = 0xff, or uart operation would be error. 2. if noise_filter code option is enable , we strongly recommend to set fcpu as fhosc/2~fhosc/16, or uart o peration would be error. if noise_filter code option is disable , the limitation doesn t exist.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 133 vers ion 1. 4 10.4 uart transfer format the uart transfer format includes bus idle status , start bit , 8 - bit data , parity bit and stop bit as following. uart transfer format with parity bit uart transfer format without parity bit bus idle status : the bus idle status is the bus non - operating status. the uart receiver bus idle status of mcu is floating sta tus and tied high by the transmitter device terminal. the uart transmitter bus idle status of mcu is high status. the uart bus will be set when urxen and utxen are enabled. start bit : uart is a asynchronous type of communication and need a attention bit to offer receiver the transfer starting. the start bit is a simple format which is high to low edge change and the duration is one bit period. the start bit is easily recognized by the receiver. 8 - bit data : the data format is 8 - bit length, and lsb transfe rs first following start bit. the one bit data duration is the unit of uart baud rate controlled by register. parity bit : the parity bit purpose is to detect data error condition. it is an extra bit following the data stream. the parity bit includes odd and even check methods controlled by urxps/utxps bits. after receiving data and parity bit, the parity check executes automatically. the urxpc bit indicates the parity check result. the parity bit function is controlled by urxpen/utxpen bits. if the parity bit function is disabled, the uart transfer contents remove the parity bit and the stop bit follows the data stream directly. stop bit : the stop bit is like start bit using a simple format to indicate the end of uart transfer. the stop bit format is low to high edge change and the duration is one bit period. 10.5 break pocket the break pocket is an empty stream to reset uart bus. break pocket is like a long time zero pocket, and the period is 88us~1s. tx break pocket: uart build s in a utxbrk bit to transmit break pocket. when utxen = 1 (enable uart tx function), set utxbrk bit to transmit break pocket. when break pocket finishes transmitting, utxirq is set as 1, and utxbrk is cleared automatica lly. the period of transmitted bre ak pocket is 25 uart baud rate clocks. if yart baud rate is 250000bps, the break pocket period is 100us . uart tx break pocket period = 25/uart baud rate sec rx break pocket: uart receives break pocket will get a frame error signal because the d ata period is longer than typical uart duration. uart cant receive a complete data pocket. after receiving a uart pocket, the break pocket is still output low. uart issues frame error flag (ufmer = 1) and u rxirq. maybe the parity bit is error in parity mo de. uart changes to initial status until detecting next start bit. b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7 s t a r t s t o p p b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7 s t a r t s t o p b r e a k 8 8 u s ~ 1 s
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 134 vers ion 1. 4 10.6 abnormal pocket the abnormal pocket occurs in uart rx mode. break pocket is one abnormal pocket of the uart architecture. the abnormal pocket includes stream period error, start bit erro r, stop bit errorwhen uart receives abnormal pocket, the ufmer bit will be set 1, and uart issues urxirq. the system finds the abnormal pocket through firmware. uart changes to initial status until detecting next start bit. uart check the start bit is error and issue ufmer flag, but the uart still finishes receiving the pocket. uart check the stop bit is error and issue ufmer flag, but the uart still finishes receiving the pocket. if the hosts uart baud rate isnt match to receiver terminal, the received pocket is error. but it is not easy to differentiate the pocket is correct or not, because the received error pocket maybe match uart rule, but the data is error . use checking ufmer bit and urxpc bit status to decide the stream. if the two conditions seem like correct, but the pocket is abnormal, uart will accept the pocket as correct one. 10.7 uart receiver contro l register 0e5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 b it 1 bit 0 urrx urxen urxpen urxps urxpc ufmer urs2 urs1 urs0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 urxen : uart rx control bit. 0 = disable uart rx. urx pin is gpio mode or returns to gpio status. 1 = enable ua rt rx. urx pin exchanges from gpio mode to uart rx mode. bit 6 urxpen : uart rx parity bit control bit. 0 = disable uart rx parity bit function. the data stream doesnt include parity bit. 1 = enable uart rx parity bit function. the data stream includes parity bit. bit 5 utxps : uart rx parity bit format control bit. 0 = uart rx parity bit format is even parity. 1 = uart rx parity bit format is odd parity. bit 4 urxpc : uart rx parity bit checking flag. 0 = parity bit is correct or no parity function. 1 = parity bit is error. bit 3 ufmer : uart rx stream frame error flag bit. 0 = collect uart frame. 1 = uart frame is error including s tart/stop bit, stream length. bit [2:0] urs[2:0] : uart per - scal a r select bit. 000 = fhosc/1, 001 = fhosc/2, 010 = fh osc/4, 011 = fhosc/8, 100 = fhosc/16, 101 = fhosc/32, 110 = fhosc/64, 111 = fhosc/128. b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7 s t a r t s t o p p u r x p i n s t a r t b i t i s e r r o r . b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7 s t a r t s t o p p u r x p i n s t a r t b i t i s e r r o r . b 0 s t a r t u a r t r x p r o c e s s o r b 1 b 2 b 3 b 4 b 5 b 6 b 7 p s t o p b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 u r x p i n s t a r t
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 135 vers ion 1. 4 10.8 uart transmitter con trol register 0e4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urtx utxen utxpen utxps utxbrk urxbz utxbz - - read/write r/w r/w r/w r/w r r - - after reset 0 0 0 0 0 0 - - bit 7 utxen : uart tx control bit. 0 = disable uart tx. utx pin is gpio mode or returns to gpio status. 1 = enable uart tx. utx pin exchanges from gpio mode to uart tx mode and idle high status. bit 6 utxpen : uart tx parity bit control bit. 0 = disable uart tx parity bit function. the data stream doesnt include parity bit. 1 = enable uart tx parity bit function. the data stream includes parity bit. bit 5 utxps : uart tx parity bit format control bit. 0 = uart tx pa rity bit format is even parity. 1 = uart tx parity bit format is odd parity. bit 4 utxbrk : uart tx break pocket control bit. 0 = end of transmitting uart break pocket. 1 = start to transmit uart break pocket. bit 3 urxbz : uart rx operating status fl ag. 0 = uart rx is idle or the end of processing. 1 = uart rx is busy and processing. bit 2 utxbz : uart tx operating status flag. 0 = uart tx is idle or the end of processing. 1 = uart tx is busy and processing. ? note: urxbz and utxbz bits are uart operating indicators. after setting uart rx/tx operations, set ( 2*fcpu/ fuart)*nop instruction is necessary, and then check uart status through urxbz and utxbz bits. 10.9 uart data buffer 0 e7 h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 utxd utxd7 utx d6 utxd5 utxd4 utxd3 utxd2 utxd1 utxd 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] utxd : uar t transmitted data buffer. 0 e8 h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ur xd utxd27 utxd26 utxd25 utxd24 utxd23 ut xd22 utxd21 utxd20 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] urxd: uart received data buffer.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 136 vers ion 1. 4 10.10 uart operation examl pe ? uart tx configuration : ; select parity bit function . b0bclr futxpen ; disable uart tx par ity bit function. ;or b0bset futxpen ; enable uart tx parity bit function. ; select parity bit format. b0bclr futxps ; uart tx parity bit format is even parity. ;or b0bset futxps ; uart tx parity bit format is odd parity. ; set uart baud rate . mov a, # value1 ; set uart pre - scaler urs[2:0]. b0mov urrx , a mov a, # value 2 ; set uart baud rate 8 - bit buffer. b0mov urcr , a ; enable uart tx pin . b0bset futxen ; enable uart tx function and uart tx pin . ; ena ble uart tx interrupt function. b0bclr futxirq ; clear uart tx interrupt flag. b0bset futxien ; enable uart tx interrupt function. ; load tx data buffer and execute tx transmitter . mov a, # value 3 ; load 8 - bit data to utxd data buffer. b0mov utxd , a ;after loading utxd, uart tx starts to transmit. nop ; one instruction delay for utxbz flag. ; check tx operation. b0bts0 futxbz ; check utxbz bit. jmp chktx ; utxbz=1, tx is operating. jmp endtx ; utxbz=0, the end of tx. ? note: uart tx operation is started through loading utxd data buffer.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 137 vers ion 1. 4 ? transmit break pocket : ; select parity bit function . b0bclr futxpen ; disable uart tx parity bit function. ;or b0bset futxpen ; enable uart tx parity bit function. ; select parity bit format. b0bclr futxps ; uart tx parity bit format is even parity. ;or b0bset futxps ; uart tx parity bit format is odd parity. ; set uart baud rate . mov a, # value1 ; set uart pre - scaler urs[2:0]. b0mov urrx , a mov a, # value 2 ; set uart baud rate 8 - bit buffer. b0mov urcr , a ; enable uart tx pin . b0bset futxen ; enable uart tx function and uart tx pin . ; enable uart tx interrupt function. b0bclr futxirq ; clear uart tx interrupt flag. b0bset futxien ; enable uart tx interrupt function. ; start uart break pocket . b0bset futxbrk ; transmit uart break pocket. nop ; one instruction delay for utxbz flag. ; check tx operation. b0bts0 futxbz ; check utxbz bit. jmp chktx ; utxbz=1, tx is operating. jmp endtx ; utxbz=0, the end of tx. ? note: uart tx break pocket is controlled by utxbrk bit and needn t load utxd buffer.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 138 vers ion 1. 4 ? uart rx configuration : ; select parity bit function . b0bclr furxpen ; disable uart rx p arity bit function. ;or b0bset furxpen ; enable uart rx parity bit function. ; select parity bit format. b0bclr furxps ; uart r x parity bit format is even parity. ;or b0bset furxps ; uart r x parity bit format is odd parity. ; set uart baud rate . mov a, # value1 ; set uart pre - scaler urs[2:0]. b0mov urrx , a mov a, # value 2 ; set uart baud rate 8 - bit buffer. b0mov urcr , a ; enable uart rx pin . b0bset furxen ; enable uart rx function and uart rx pin . ; enable uart rx interrupt function. b0bclr furxirq ; clear uart rx interrupt flag. b0bset furxien ; enable uart rx interrupt function. nop ; one instruction delay for urxbz flag. ; check rx operation. b0bts0 furxbz ; check urxbz bit. jmp chkrx ; urxbz=1, rx is operating. jmp endrx ; urxbz=0, the end of rx. ? note: uart rx operation is started as start bit transmitted from master terminal.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 139 vers ion 1. 4 1 1 1 1 1 1 serial input/output transceiver (sio) 11.1 overview the sio (serial input/output) tr ansceiver is a serial communicate interface for data exchanging from one mcu to one mcu or other hardware peripherals. it is a simple 8 - bit interface without a major definition of protocol, packet or control bits. the sio transceiver includes three pins, c lock (sck), data input (si) and data output (so) to send data between master and slaver terminals. the sio interface builds in 8 - mode which are the clock idle status, the clock phases and data fist bit direction. the 8 - bit mode supports most of sio/spi com municate format. the sio features include the following: ? full - duplex, 3 - wire synchronous data transfer. ? master (sck is clock output) or slave (sck is clock input) operation. ? msb/lsb first data transfer. ? the start phase of data sampling location select ion is 1 st - phase or 2 nd - phase controlled register. ? sck, si, so are programmable open - drain output pin for multiple salve devices application. ? two programmable bit rates (only in master mode). ? end - of - transfer interrupt. 11.2 sio operation the siom register c an control sio operating function, such as: transmit/receive, clock rate, data transfer direction, sio clock idle status and clock control phase and starting this circuit. this sio circuit will transmit or receive 8 - bit data automatically by setting senb a nd start bits in siom register. the sio data buffer is double buffer design. when the sio operating, the siob register stores transfer data and one internal buffer stores receive data. when sio operation is successfully, the internal buffer reloads into si ob register automatically. the sio 8 - bit counter and sior register are designed to generate sios clock source with auto - reload function. the 3 - bit i/o counter can monitor the operation of sio and announce an interrupt request after transmitting/ receiving 8 - bit data. after transferring 8 - bit data, this circuit will be disabled automatically and re - transfer data by programming siom register. cpol bit is designed to control sio clock idle status. cpha bit is designed to control the clock edge direction of da ta receive. cpol and cpha bits decide the sio format. the sio data transfer direction is controlled by mlsb bit to decide msb first or lsb first. sio interface structure diagram 1 f c p u c p u m 1 , 0 s e n b s c k s c l k m d s i o 8 - b i t c o u n t e r s i o r r e g i s t e r a u t o - r e l o a d c p o l s i o 3 - b i t i / o c o u n t e r s i o t i m e o u t s i o b 8 - b i t b u f f e r 8 - b i t r e c e i v e b u f f e r m l s b s o s i s e n b m l s b c p h a s r a t e 1 , 0 s t a r t s e n b s e n b s c s s c s e n , s c l k m d = 1 s c s p s e n b
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 140 vers ion 1. 4 the sio supports 8 - mode format controlled by mlsb, cpol and cpha bits. the edge direction is data transfer edge. when setting rising edge that means to receive and transmit one bit data at sck rising edge, and data transition is at sck falling edge. when setting falling edge, that means to receive and transmit one bit data at sck falling edge, and data transition is at sck rising edge. cpha is the clock phase bit controls the phase of the clock on which data is sampled. when cpha=1, the sck first edge is for data transition, and receive and trans mit data is at sck 2 nd edge. when cpha=0, the 1 st bit is fixed already, and the sck first edge is to receive and transmit data. the sio data transfer timing as following figure: m l s b c p o l c p h a diagrams description 0 0 1 sck idle status = low. the transfer first bit = msb. sck data transfer edge = falling edge. 0 1 1 sck idle status = high . the transfer first bit = msb. sck data transfer edge = rising edge. 0 0 0 sc k idle status = low. the transfer first bit = msb. sck data transfer edge = rising edge. 0 1 0 sck idle status = high . the transfer first bit = msb. sck data transfer edge = falling edge. 1 0 1 sck idle status = low. the transfer first bit = l sb. sck data transfer edge = falling edge. 1 1 1 sck idle status = high . the transfer first bit = l sb. sck data transfer edge = rising edge. 1 0 0 sck idle status = low. the transfer first bit = l sb. sck data transfer edge = rising edge. 1 1 0 sck idle status = high . the transfer first bit = l sb. sck data transfer edge = falling edge. sio data transfer timing b i t 7 b i t 6 b i t 5 b i t 4 b i t 3 b i t 2 b i t 1 b i t 0 b i t 7 b i t 6 b i t 5 b i t 4 b i t 3 b i t 2 b i t 1 b i t 0 b i t 7 b i t 6 b i t 5 b i t 4 b i t 3 b i t 2 b i t 1 b i t 0 n e x t d a t a b i t 7 b i t 6 b i t 5 b i t 4 b i t 3 b i t 2 b i t 1 b i t 0 n e x t d a t a b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7 b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7 n e x t d a t a b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7 n e x t d a t a b i t 0 b i t 1 b i t 2 b i t 3 b i t 4 b i t 5 b i t 6 b i t 7
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 141 vers ion 1. 4 the sio supports interrupt function . sioien is sio interrupt function control bit. sioien=0, disable sio interrupt function . sioien=1, enable sio interrupt function. when sio interrupt function enable, the program counter points to interrupt vector (org 0011h ) to do sio interrupt service routine after sio operating. sioirq is sio interrupt request flag, and also to be the sio operating status indicator when sioien = 0, but cleared by program. when sio operation finished, the sioirq would be set to 1 , and the operation is the inverse status of sio start control bit. the sioirq and sio start bit indicating the end status of sio operation is after one 8 - bit data transferring . the duration from sio transfer end to sioirq/start active is about 1/2 *sio clock , means the sio end indicator doesn t active immediately . ? note: the first step of sio operation is to setup the sio pins mode. enable senb, select cpol and cpha bits. these bits control sio pins mode. sio builds in chip selection function to imple ment sio multi - device mode. one master communicating with several slave devices in sio bus, and the chip selection decides the pointed device. the chip selection pin is scs pin and controlled by scsen bit. the scs function only supports salve mode (sckmd=1 ). the scs includes two phases which are high active and low active controlled by scsp bit. scsp=1, scs pin idle mode is high and low active. scsp=0, scs pin idle mode is low and high active. sio operation is controlled by start bit. in scs enable mode, se t start bit doesnt mean sio active. the scs condition is a necessary condition. if the scs status doesnt exist, the sio bus keeps idle status until scs status meets configuration. sio builds in siobz bit to indicate sio processing status. siobz=1 means sio is processing. siobz=0 means sio is in idle status or the end of sio processing. when sio bus starts to execute, the siobz bit changes to logic high status. when sio bus finishes transmitting, the siobz bit changes to logic low status. siobz operation of different modes is as below diagram. s c k s i s o s c s p i n , s c s p = 0 s c s p i n , s c s p = 1 s e t s t a r t = 1 s i o b u s a c t i v e s i o b z
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 142 vers ion 1. 4 11.3 siom mode register 0e0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 siom senb start srate1 srate0 mlsb sckmd cpol cpha read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 senb: sio function control bit. 0 = disable sio function. sio pins are gpio. 1 = enable sio function. gpio pins are sio pins. sio pin structure can be push - pull structure and open - drain structure controlled by p 1 oc register. bit 6 start: sio progress control bit. 0 = end of transfer. 1 = sio transmitting. bit [5:4] srate1,0: sios transfer rate select bit. these 2 - bits are workless when sckmd=1. 00 = fcpu. 01 = fcpu/32. 10 = fcpu/16. 11 = fcpu/8. bit 3 mlsb: msb/lsb transfer fi rst. 0 = msb transmit first. 1 = lsb transmit first. bit 2 sckmd: sios clock mode select bit. 0 = internal. (master mode) 1 = external. (slave mode) bit 1 cpol: sck idle status control bit. 0 = sck idle status is low status. 1 = sck idle status is hi gh status. bit 0 cpha: the clock phase bit controls the phase of the clock on which data is sampled. 0 = data receive at the first clock phase. 1 = data receive at the second clock phase. 0e3h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sio c - - - - - siobz scsen scsp read/write - - - - - r r/w r/w after reset - - - - - 0 0 0 bit 2 sio bz : sio operating status flag. 0 = sio is idle or end of processing. 1 = sio is busy and processing. bit 1 scsen : sio chip selection function control bit. 0 = disable chip selection function. scs pin keeps and returns to gpio function. 1 = enable chip selection function. scs pin transmits sio chip selection pin when sckmd = 1, or keeps gpio mode. bit 0 scsp : sio chip selection direction control bit. 0 = idl e low and high active. 1 = idle high and low active.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 143 vers ion 1. 4 because sio function is shared with gpio. the following table shows the sio pin mode mode behavior and setting when sio function enable and disable. senb=1 (sio function enable) sck sckmd=1 sio so urce = external clock gpio will change to input mode automatically, no matter what pnm setting. sckmd=0 sio source = internal clock gpio will change to output mode automatically, no matter what pnm setting. si gpio must be set as input mode in pnm ,or the sio function will be abnormal so sio = transmitter/receiver gpio will change to output mode automatically, no matter what pnm setting. scs scsen=1, sckmd=1. enable chip selection function. gpio will change to input mode automatically, no matter w hat pnm setting. senb=0 (sio function disable) gpio gpio i/o mode are fully controlled by pnm when sio function disable ? note: 1. if sckmd=1 for external clock, the sio is in slave mode. if sckmd=0 for internal clock, the sio is in master mode. 2. don t se t senb and start bits in the same time . that makes the sio function error . 3. sio pin can be push - pull structure and open - drain structure controlled by p1oc register. 4. scs pin enabled condition is only sckmd=1 and scsen=1. if sckmd=0, scsen=1, the scs pin is s till gpio mode . 11.4 siob data buffer 0e2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 siob siob7 siob6 siob5 siob4 siob3 siob2 siob1 siob0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 siob is the sio data buffer register. it stores serial i/o transmit and receive data. the system is single - buffered in the transmit direction and double - buffered in the receive direction. this means that bytes to be transmitted cannot be written to the siob data register before the entire shif t cycle is completed. when receiving data, however, a received byte must be read from the siob data register before the next byte has been completely shifted in. otherwise, the first byte is lost. following figure shows a typical sio transfer between two m icro - controllers. master mcu sends sck for initial the data transfer. both master and slave mcu must work in the same clock edge direction, and then both controllers would send and receive data at the same time. sio data tra nsfer diagram shift register (siob) 2nd receive buffer (address = siob) i n t e r n a l b u s read siob write siob sio master (sckmd = 0) so si sck shift register (siob) 2nd receive buffer (address = siob) i n t e r n a l b u s read siob write siob sio slave (sckmd = 1) si so sck
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 144 vers ion 1. 4 11.5 sior register description 0e1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sio r sior7 sior6 sior5 sior4 sior3 sior2 sior1 sior0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the sior is designed for the sio counter to rel oad the counted value when end of counting. it is like a post - scalar of sio clock source and let sio has more flexible to setting sck range. users can set the sior value to setup sio transfer time. to setup sior value equation to desire transfer time is as following. sck frequency = (sio rate / (256 - sior))/2 sior = 256 - ( 1 / ( 2 * sck frequency ) * sio rate ) ? example: setup the sio clock to be 5khz. fhosc = 4mhz. sios rate = fcpu = fhosc/4. sior = 256 C (1/(2*5khz) * 4mhz/4) = 256 C (0.0001*100 0000) = 256 C 100 = 156
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 145 vers ion 1. 4 1 1 1 2 2 2 main serial port (msp) 12.1 overview the msp (main serial port) is a serial communication interface for data exchanging from one mcu to one mcu or other hardware peripherals. these peripheral devices may be serial eeprom, a/d conver ters, display device, etc. the msp module can operate in one of two modes : ? master tx,rx mode ? slave tx,rx mode (with general address call) for multiplex slave in single master situation. the msp features include the following: ? 2 - wire synchronous data t ransfer/receiver. ? master (scl is clock output) or slave (sc l is clock input) operation. ? scl, sda are programmable open - drain output pin for multiple x salve devices application. ? support 400k clock rate @ fcpu=4mips. ? end - of - transfer/rec e iver interrupt. 12.2 m sp status register 0eah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspstat - cke d_a p s red_wrt - bf read/write - r/w r r r r - r after reset - 0 0 0 0 0 - 0 bit 6 cke : slave clock edge control bit in slave mode: receive address or data byte 0= latch data on scl rising edge. (default) 1= latch data on scl falling edge. ? note: 1. in slave transmit mode, address received depended on cke setting. data transfer on scl falling edge. 2. in slave receiver mode, address and data received depended on cke setting. ? d_a_ : data/address_ bit 0=indicates the last byte received or transmitted was address. 1= indicates the last byte received or transmitted was data. bit 4 p: stop bit 0 = stop bit was not detected. 1 = indicates that a stop bit has bee n detected last. ? note: it will be cleared when start bit was detected. bit 3 s: start bit. 0 = start bit was not detected. 1 = indicates that a start bit has been detected last ? ? note: it will be cleared when stop bit was detected. ?
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 146 vers ion 1. 4 bit 2 red_wr t: read/write bit information. this bit holds the r/w bit information following the last address match. this bit is only valid from the address match to the next start bit, stop bit, or not ack bit. in slave mode : 0 = write. 1 = read. in master mode : 0 = transmit is not in progress. 1 = transmit is in progress. or this bit with sen, rsen, pen, rcen, or acken will indicate if the msp is in idle mode. bit 0 bf: buffer full status bit receive 1 = receive complete, mspbuf is full. 0 = receive not complete, m spbuf is empty. transmit 1 = data transmit in progress (does not include the ack and stop bits), mspbuf is full. 0 = data transmit complete (does not include the ack and stop bits), mspbuf is empty. 12.3 msp mode register 1 0ebh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspm1 wcol mspov mspenb ckp slrxckp mspwk - mspc read/write r/w r/w r/w r/w r/w r/w - r/w after reset 0 0 0 0 0 0 - 0 bit 7 wcol : write collision detect bit master mode : 0 = no collision 1 = a write to the sspbuf register was attem pted while the msp conditions were not valid for a transmission to be started slave mode : 0 = no collision 1 = the sspbuf register is written while it is still transmitting the previous word (must be cleared in software) bit 6 pmspov: receive overflow in dicator bit 0 = no overflow. 1 = a byte is received while the sspbuf register is still holding the previous byte. sspov is a dont care in transmit mode. sspov must be cleared in software in either mode. (must be cleared in software) bit 5 mspenb: msp communication enable. 0 = disables serial port and configures these pins as i/o port pins 1 = enables serial port and configures scl, sda as the source of the serial port pins ? note: msp status register will be clear after msp disable. so, user should sett ing msp register again before msp enable. ex: b0 bclr fmspenb c all msp_init_setting b0 bset fmspenb bit 4 ckp: scl clock priority control bit in msp slave mode 0 = hold scl keeping low. (ensure data setup time and slave device ready.) 1 = release scl clock (slave transistor mode ckp function always enables, slave receiver cpk function control by slrxckp) in msp master mode unused.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 147 vers ion 1. 4 bit 3 slrxckp: slave receiver mode scl clock priority control bit in msp slave receiver mode. 0 = disa ble ckp function. 1 = enable ckp function. in msp slave and slave transistor mode unused. bit 2 mspwk: msp wake - up indication bit 0 = mcu not wake - up by msp. 1 = mcu wake - up by msp ? note: clear mspwk before entering power down mode for indication the wa ke - up source from msp or not bit 0 mspc: msp mode control register 0 = msp operated on slave mode, 7 - bit address 1 = msp operated on master mode. 12.4 msp mode register 2 0ech bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspm2 gcen ackstat ackdt acken r cen pen rsen sen read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 gcen : general call enable bit (in slave mode only) 0 = general call address disabled 1 = enable interrupt when a general call address (0000h) is received. b it 6 ackstat : acknowledge status bit (in master mode only) in master transmit mode : 0 = acknowledge was received from slave 1 = acknowledge was not received from slave bit 5 ackdt : acknowledge data bit. (in master mode only) in master receive mode : val ue that will be transmitted when the user initiates an acknowledge sequence at the end of a receive. 0 = acknowledge 1 = not acknowledge bit 4 acken : acknowledge sequence enable bit (in msp master mode only) in master receive mode: 0 = acknowledge sequ ence idle 1 = initiate acknowledge sequence on sda and scl pins, and transmit akdt data bit. automatically cleared by hardware. bit 3 rcen: receive enable bit (in master mode only) 0 = receive idle 1 = enables receive mode for msp bit 2 pen: stop cond ition enable bit (in master mode only) 0 = stop condition idle 1 = initiate stop condition on sda and scl pins. automatically cleared by hardware. bit 1 rsen: repeated start condition enabled bit (in master mode only) 0 = repeated start condition idle. 1 = initiate repeated start condition on sda and scl pins. automatically cleared by hardware. bit 0 sen: start condition enabled bit (in master mode only) 0 = start condition idle 1 = initiate start condition on sda and scl pins. automatically cleared by hardware.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 148 vers ion 1. 4 12.5 msp mspbuf register mspbuf initial value = 0000 0000 0edh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspbuf mspbuf7 mspbuf6 mspbuf5 mspbuf4 mspbuf3 mspbuf2 mspbuf1 mspbuf0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 12.6 msp mspadr register mspadr initial value = 0000 0000 0eeh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspadr mspadr7 mspadr6 mspadr5 mspadr4 mspadr3 mspadr2 mspadr1 mspadr0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:1] 7 - bit address. bit 0 tx/rx mode control bit. 0=tx mode. 1=rx mode. 12.7 slave mode operation when an address is matched or data transfer after and address match is received, the hardware automatically will generate the acknowledge (ack_) sign al, and load mspbuf (msp buffer register) with the received data from mspsr. there are some conditions that will cause msp function will not reply ack_ signal: ? data buffer already full: bf=1 (mspstat bit 0), when another transfer was received. ? data overf low: mspov=1 (mspm1 bit 6), when another transfer was received when bf=1, means mspbuf data is still not read by mcu, so mspsr will not load data into mspbuf, but mspirq and mspov bit will still set to 1. bf bit will be clear automatically when reading ms pbuf register. mspov b it must be clear through by sof t ware. 12.7.1 addressing when msp slave function has been enabled, it will wait a start signal occur. following the start signal, 8 - bit address will shift into the mspsr register. the data of mspsr[7:1] is com pare with mspadr register on the falling edge of eight scl pulse, if the address are the same, the bf and sspov bit are both clear, the following event occur: 1. mspsr register is loaded into mspbuf on the falling edge of eight scl pulse. 2. buffer full bit (bf ) is set to 1, on the falling edge of eight scl pulse. 3. an ack_ signal is generated. 4. msp interrupt request mspirq is set on the falling edge of ninth scl pulse. status when data is received mspsp ? mspbuf reply an ack_ signal set mspirq bf mspov 0 0 ye s yes yes *0 *1 yes no yes 1 0 no no yes 1 1 no no yes data received action table ? note: bf=0, mspov=1 shows the software is not set properly to clear overflow register.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 149 vers ion 1. 4 12.7.2 slave receiving when the r/w bit of address byte =0 and address is matched, the r/w bit of mspstat is cleared. the address will be load into mspbuf. after reply an ack_ signal, msp will receive data every 8 clock. the ckp function enable or disable (default) is controlled by slrxckp bit and data latch edge - rising edge (default) o r falling edge is controlled by cpe bit. when overflow occur, no acknowledge signal replied which either bf=1 or mspov=1. msp interrupt is generated in every data transfer. the mspirq bit must be clear by software. following is the slave receiving diagram slrxckp=0 slrxckp=1 12.7.3 slave transmission after address match, the following r/w bit is set, mspstat bit 2 r/w will be set. the received address will be load to mspbuf and ack_ will be sent at ninth clock then scl will be hol d low. transmission data will be load into mspbuf which also load to mspsr register. the master should monitor scl pin signal. the slave device may hold on the master by keep ckp low. when set. after load mspbuf, set ckp bit, mspbuf data will shift out on the falling edge on scl signal. this will ensure the sda signal is valid on the scl high duty. an msp interrupt is generated on every byte transmission. the mspirq will be set on the ninth clock of scl. clear mspirq by software. mspstat register can monito r the status of data transmission. in slave transmission mode, an ack_ signal from master - receiver is latched on rising edge of ninth clock of scl. if ack_ = high, transmission is complete. slave device will reset logic and waiting another start signal. if ack_= low, slave must load mspbuf which also mspsr, and set ckp=1 to start data transmission again. s r e c e i v i n g a d d r e s s a c k _ 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 a c k _ 1 d 7 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 9 8 d 0 1 d 7 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 8 d 0 9 p s d a s c l m s p i r q a c k _ b f s s p o v r e c e i v i n g d a t a r e c e i v i n g d a t a c l e a r e d b y s o f t w a r e m s p o v = 1 , b e c a u s e m s p b u f s t i l l f u l l ( b f = 1 ) t e r m i n a t e b y m a s t e r a c k _ n o t s e n t r e a d m s p b u f r / w = 0 s r e c e i v i n g a d d r e s s a c k _ 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 a c k _ 1 d 7 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 9 8 d 0 1 d 7 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 8 d 0 9 p s d a s c l m s p i r q a c k _ b f s s p o v c k p r e c e i v i n g d a t a r e c e i v i n g d a t a c l e a r e d b y s o f t w a r e m s p o v = 1 , b e c a u s e m s p b u f s t i l l f u l l ( b f = 1 ) t e r m i n a t e b y m a s t e r a c k _ n o t s e n t r e a d m s p b u f r / w = 0 s e t c k p a f t e r r e a d m s p b u f s e t c k p , n o t r e a d m s p b u f s e t c k p
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 150 vers ion 1. 4 msp slave transmission timing diagram 12.7.4 general call address in msp bus, the first 7 - byte is the slave addres s. only the ad dress match mspad r the slave will response an ack_. the exception is the general call address which can address all slave devices. when this address occur, all devices should response an acknowledge. the general call address is a special address which is reserved as all 0 of 7 - bytes address. the general call address function is control by gcen bit. set this bit will enable general call address and clear it will disable. when gecn=1, following a start signal, 8 - bit will shift into mspsr and the address is compared with mspadd and also the general call address which fixed by hardware. if the genera call address matches, the mspsr data is transferred into mspbuf, the bf flag bit is set, and in the falling edge of the ninth clock (ack_) mspirq flag set for i nterrupt request. in the interrupt service routine, reading mspbuf can check if the address is the general call address or device specific. general call address timing diagram s r e c e i v i n g a d d r e s s a c k _ 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 r / w = 0 a c k _ 1 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 8 d 0 9 p s d a s c l m s p i r q b f c k p t r a n s m i s s i o n d a t a c l e a r e d b y s o f t w a r e m s p b u f i s w r i t i n g b y s o f t w a r e r / w = 1 s e t c k p a f t e r w r i t i n g t o m s p b u f } i n t e r r u p t s e r v i c e r o u t i n e d 7 s a c k _ 1 2 3 4 5 6 7 8 9 0 1 d 7 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 9 8 d 0 s d a s c l m s p i r q b f s s p o v g c e n r e c e i v i n g d a t a c l e a r e d b y s o f t w a r e r e a d m s p b u f r / w = 0 g e n e r a l c a l l a d d r e s s 1 a c k _ a f t e r a c k _ , s e t i n t e r r u p t a d d r e s s c o m p a r e t o g e n e r a l c a l l a d d r e s s
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 151 vers ion 1. 4 12.7.5 slave wake up when mcu enter power down mode, if msbenb bit is still set, mcu can wake - up by matched device address. the address of msp bus following start bit, 8 - byte address will shift into mspsr, if address matched, an not acknowledge will response on the ninth clock of scl and mcu will be wake - up , mspwkset and start wake - up procedure but mspirq will not set and mspsr data will not load to mspubf. after mcu finish wake - up procedure, msp will be in idle status and waiting masters start signal. control register bf, mspirq, mspov and mspbuf will be t he same status/data before power down. if address not matches, a not acknowledge is still sent on the ninth clock of scl, but mcu will be not wake - up and still keep in power down mode. msp wake - up timing diagram: address not m atched msp wake - up timing diagram: address matched after into power down mode, we need to disable msp and then enable msp to reset msp function and r e - write the i2c slave address . ? example: b 0bset fcpum0 b0bclr fmspenb nop b0bset fmspenb mov a, #0x nn b0mov mspadr, a ; re - write the i2c slave address again. s r e c e i v i n g a d d r e s s 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 a c k _ p s d a s c l m s p i r q b f r / w 0 0 w a k e - u p 0 m s p w k 0 m c u m o d e c l e a r m s p w k , s e t f c p u m 0 ( p o w e r d o w n ) n o r m a l m o d e p o w e r d o w n m o d e s r e c e i v i n g a d d r e s s 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 a c k _ p s d a s c l m s p i r q b f r / w w a k e - u p n o r m a l m o d e c l e a r m s p w k , s e t f c p u m 0 ( p o w e r d o w n ) m c u w a k e - u p s t a r t w a r m - u p m c u m o d e w a r m - u p t i m e n o r m a l m o d e ( o p - c o d e e x e c u t i n g ) p o w e r d o w n m o d e s r e c e i v i n g a d d r e s s a c k _ 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 a c k _ 1 d 7 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 9 8 d 0 r e c e i v i n g d a t a c l e a r e d b y s o f t w a r e r e a d m s p b u f r / w = 0 m s p w k c l e a r m s p w k b y s o f t w a r e
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 152 vers ion 1. 4 ? note: 1. msp function only can work on normal mode, when wake - up from power down mode, mcu must operate in normal mode before master sent start sign al. 2. in msp wake - up, if the address not matches, mcu will keep in power down mode. 3. clear mspwk before enter power down mode by software for wake - up indication.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 153 vers ion 1. 4 12.8 master mode master mode of msp operation from a start signal and end by stop signal. the start (s) and stop (p) bit are clear when reset or msp function disabled. in master mode the scl and sda line are controlled by msp hardware. following events will set msp interrupt request (mspirq), if mspien set, interrupt occurs. ? start condition ? st op condition ? data byte transmitted or received ? acknowledge transmit. ? repeat start. 12.8.1 mater mode support master mode enable when mspc and mspenb bit set. once the master mode enabled, the user had following six options. ? send a start signal on scl and sda lin e. ? send a repeat start signal on scl and sda line. ? write to mspbuf register for data or address byte transmission ? send a stop signal on scl and sda line. ? configuration msp port for receive data ? send an acknowledge at the end of a received byte of data. 12.8.2 ms p rate generator in msp mode, the msp rate generators reload value is loc ated in the lower 7 bit of mspa dr register. when mrg is loaded with the register, the mrg count down to 0 and stop until another reload has taken place. in msp mater mode mrg reload from mspa dr automatically. if clock arbitration occur for instance (scl pin keep low by slave device), the mrg will reload when scl pin is detected high. scl clock rate = fcpu/(mspad r)*2 for example, if we want to se t 400khz in 4mhz fcpu, the mspa dr have to set 0x05h. mspa dr=4mhz/400khz*2=5 msp rate generator block diagram mrg timing diagram with and w ithout clock arbitration (mspad r=0x03) s d a s c l 3 2 1 0 3 2 1 0 3 2 1 0 3 2 n o c l o c k a r b i t r a t i o n d x - 1 d x - 2 m r g d o w n c o u n t e r m r g r e l o a d d x s d a s h i f t i n n e x t b i t d a t a c l o c k a r b i t r a t i o n s l a v e r e l e a s e s c l c l o c k , s c l a l l o w e d t o t r a n s i t i o n h i g h . f c p u / 4 s c l i s s a m p l e d h i g h , r e l o a d o c c u r r e d a n d m r g d o w n c o u n t e r s t a r t s c o u n t
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 154 vers ion 1. 4 12.8.3 msp mater start condition to generate a start signal, user sets sen bit (mspm2.0). w hen sda and scl pin are both sampled high, msp rate generator reload mspa dr[6:0], and starts down counter. when sda and scl are both sampled high and mrg overflow, sda pin is drive low. when scl sampled high, and sda transmitted from high to low is the sta rt signal and will set s bit (mspstat.3). mrg reload again and start down counter. sen bit will be clear automatically when mrg overflow, the mrg is suspend leaving sda line held low, and start condition is complete. 12.8.3.1 wcol status flag if user write to mspb uf when start condition processing, then wcol is set and the content of mspbuf data is un - changed. ( t he writer doesnt occur) start condition timing diagram 12.8.4 msp master mode repeat start condition when msp logic module is idle and rsen set to 1, repeat start progress occurs. rsen set an d scl pin is sampled low, mspad r[6:0] data reload to msp rate generator and start down counter. the sda pin is release to high in one msp rate generate counter (t mrg ). when the mrg is overflow, if sda is sampled high. scl will be brought high. when scl is sampled high, mspa dr reload to mrg and start down counter. sda and scl must keep high in one t mrg period. in the next t mrg period, sda will be brought low when scl is sampled high, then rsen will clear automatically by hardware and mrg will not reload, leaving sda pin held low. once detect sda and scl occur start condition, the s bit will be set (mspstat.3). mspirq will not set until mrg overflow. ? note: 1. while any other event is progress, set rsen will take no effect. 2. a bus collision during the repeat start condition occurs: sda is sampled low when scl goes from low to high. 12.8.4.1 wcol status flag if user write to mspbuf when repeat start condition processing, then wcol is set and the content of mspbuf data is un - changed. (the writer doesnt occur) repeat start condition timing diagram s d a s c l 1 s t - b i t 2 n d - b i t c o m p l e t e s r a r t s i g n a l , h a r d w a r e c l e a r s e n b i t , s e t m s p i r q b i t s d a = 1 s c l = 1 t m r g t m r g s e t s b i t ( m s p s t a t . 3 ) s w r i t e m s p b u f h e r e w r i t e s e n h e r e t m r g t m r g t m r g s d a s c l 1 s t - b i t s d a = 1 s c l n o c h a n g e r s = r e p e a t s t a r t w r i t e r s e n h e r e t m r g t m r g f a l l i n g e d g e o f n i n t h c l o c k , e n d o f t r a n s m i s s i o n s d a = 1 , s c l = 1 t m r g s e t s b i t c o m p l e t e o f s t a r t b i t , h a r d a r e c l e a r e s e n b i t a n d s e t m s p i r q t m r g t m r g w r i t e t o m s p b u f h e r e
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 155 vers ion 1. 4 12.8.5 acknowledge sequence timing an acknowledge sequence is enabled when set acken (mspm2.4). scl is pulled low when set acken and the content of the acknowledge data bit is present on sda pin. if user whished to reply a acknowledge, ackdt bit should be cleared. if not, set ackdt bit before starting a acknowledge sequence. scl pin will be release (brought high) when msp rate generato r overflow. msp rate generator start a t mrg period down counter, when scl is sampled high. after this period, scl is pulled low, and acken bit is clear automatically by hardware. when next mrg overflow again, msp goes into idle mode. 12.8.5.1 wcol status flag if u ser write to mspbuf when acknowledge sequence processing, then wcol bit is set and the content of mspbuf data is un - changed. (the writer doesnt occur) acknowledge sequence timing diagram 12.8.6 stop condition timing at the end of received/transmitted, a stop signal present on sda pin by setting the stop bit register, pen (mspm2.1). at the end of receive/transmit, scl goes low on the failing edge of ninth clock. master will set sda go low, when set pen bit. when sda is sampled low, msp rate generator is reloaded and start count down to 0. when mrg overflow, scl pin is pull high. after one t mrg period, sda goes high. when sda is sampled high while scl is high, bit p is set. pen bit is clear after next one t mrg period, and mspirq is se t. 12.8.6.1 wcol status flag if user write to mspbuf when a stop condition is processing, then wcol bit is set and the content of mspbuf data is un - changed. (the writer doesnt occur) stop condition sequence timing diagram s d a s c l d 0 s e t m s p i r q a t t h e e n d o f r e c e i v e t m r g t m r g 8 9 w r i t e a c k e n = 1 , a c k n d t = 0 a c k n o w l e d g e s e q u e n c e s t a r t h e r e a c k _ a c k e n c l e a r e d a u t o m a t i c a l l y m s p i r q c l e a r m s p i r q b y s o f t w a r e s e t m s p i r q a t t h e e n d o f a c k n o w l e d g e s e q u e n c e c l e a r m s p i r q b y s o f t w a r e s d a s c l t m r g t m r g f a l l i n g e d g e o f n i n t h e d g e p p b i t i s s e t t m r g s e t p e n h e r e s d a g o e s l o w b e f o r e t h e r i s i n g e d g e o f s c l t o s e t u p s t o p s i g n a l s c l g o e s h i g h o n n e x t t m r g t m r g p e n i s c l e a r b y h a r d w a r e a n d m s p i r q b i t i s s e t
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 156 vers ion 1. 4 12.8.7 clock ar bitration clock arbitration occurs when the master, during any receive, transmit or repeat start, stop condition that scl pin allowed to float high. when scl pin is allowed float high, the master rate generator (mrg) suspended from counting until the scl p in is actually sampled high. when scl is sampled high, the mrg is reloaded with the content of msp a dr[6:0], and start down counter. this ensure that scl high time will always be at least one mrg overflow time in the event that the clock is held low by an e xternal device. clock arbitration sequence timing diagram 12.8.8 master mode transmission transmission a data byte, 7 - bit address or the eight bit data is accomplished by simply write to mspbuf register. this operation will set the b uffer full flag bf and allow msp rate generator start counting. after write to mspbuf, each bit of address will be shifted out on the falling edge of scl until 7 - bit address and r/w_ bit are complete. on the failing edge of eighth clock, the master will pu ll low sda fort slave device respond with an acknowledge. on the ninth clock falling edge, sda is sampled to indicate the address already accept by slave device. the status of the ack bit is load into ackstat status bit. then mspirq bit is set, the bf bit is clear and the mrg is hold off until another write to the mspbuf occurs, holding scl low and allow sda floating. 12.8.8.1 bf status flag in transmission mode, the bf bit is set when user writes to mspbuf and is cleared automatically when all 8 bit data are shift out. 12.8.8.2 wcol flag if user write to mspbuf during transmission sequence in progress, the wcol bit is set and the content of mspbuf data will unchanged. 12.8.8.3 ackstat status flag in transmission mode, the ackstat bit is cleared when the slave has sent an acknowled ge (ack_=0), and is set when slave does not acknowledge (ack_=1). a slave send an acknowledge when it has recognized its address (including general call), or when the slave has properly received the data. msp master transmissi on mode timing diagram s d a s c l t m r g m r g o v e r f l o w , r e l e a s s c l , i f s c l = 1 , r e l o a d m r g w i t h m s p a d r a n d s t a r t c o u n t d o w n t o m e a s u r e h i g h t i m e i n t e r v a l s c l p i n s m a p l e e d o n c e e v e r y f c p u / 4 , h o l d o f m r g u n t i a l s c l i s s a m p l e d h i g h t m r g t m r g m r g o v e r f l o w , r e l e a s e s c l , s l a v e d e v i c e h e l d t h e s c l l o w s c l = 1 , m r g s t a r t c o u n t i n g c l o c k h i g h i n t e r v a l s t r a n s m i t a d d r e s s a c k _ = 0 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 a c k _ 1 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 8 d 0 9 p s d a s c l m s p i r q b f s e n t r a n s m i s s i o n d a t a c l e a r e d b y s o f t w a r e r / w = 0 w r i t e s e n = 1 , s t a r t c o n d i t i o n b e g i n s s e n = 0 d 7 p e n r / w _ w r i t e a d d r e s s a n d r / w t o m s p b u f s t a r t t r a n s m i t w r i t e m s p b u f s e n c l e a r e d b y h a r d w a r e , a f t e r s t a r t c o n d i t i o n f r o m s l a v e , c l e a r a c k s t a t s c l h e l d l o w , w h i l e m a s t e r r e s p o n s e m s p i r q c l e a r e d b y s o f t w a r e a c k s t a t = 1 c l e a r e d b y s o f t w a r e s e r v i c e r o u t i n e o f m s p i n t e r r u p t w r i t e m s p b u f
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 157 vers ion 1. 4 12.8.9 master mode receiving master receiving mode is enable by set rcen bit. the mrg start counting and when scl change state from low to high, the data is shifted into mspsr. after the falling edge of eighth clock, the receive enable bi t (rcen) is clear automatically, the contents of msp are load into mspbuf, the bf flag is set, the mspirq flag is set and mrg counter is suspended fro, counting, holding scl low. the msp is now in idle mode and awaiting the next operation command. when the mspbuf data is read by software, the bf flag is cleat automatically. by setting acken bit, user can send an acknowledge bit at the end of receiving. 12.8.9.1 bf status flag in reception mode, the bf bit is set when an address or data byte is loaded into mspbuf fr om mspsr. it is cleared automatically when mspbuf is read. 12.8.9.2 mspov flag in receive operation, the mspov bit is set when another 8 - bit are received into mspsr, and the bf bit is already set from previous reception 12.8.9.3 wcol flag if user write to mspbuf when a re ceive is already progress, the wcol bit is set and the content of mspbuf data will unchanged. msp master receiving mode timing diagram s t r a n s m i t a d d r e s s t o s l a v e a c k _ = 0 1 a 7 2 a 6 3 a 5 4 a 4 5 a 3 6 a 2 7 a 1 8 9 a c k _ 1 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 8 s d a s c l m s p i r q b f m s p o v r e c e i v i n g d a t a f r o m s l a v e c l e a r e d b y s o f t w a r e r / w = 1 w r i t e s e n = 1 , s t a r t c o n d i t i o n b e g i n s s e n = 0 d 7 a c k e n w r i t e a d d r e s s a n d r / w t o m s p b u f s t a r t t r a n s m i t w r i t e m s p b u f f r o m s l a v e , c l e a r a c k s t a t c l e a r e d b y s o f t w a r e 1 2 d 6 3 d 5 4 d 4 5 d 3 6 d 2 7 d 1 p 9 d 6 a c k _ 9 8 d 0 c l e a r e d b y s o f t w a r e w r i t e r c e n = 1 d 0 r c e n c l e a r e d a u t o m a t i c a l l y w r i t e a c k e n = 1 s t a r t a c k n o w l e d g e s e q u e n c e , s d a = a c k d t = 0 a c k f r o m m a s t e r s d a = a c k d t = 0 w r i t e r c e n = 1 , s t a r t n e x t r e c e i v e r e c e i v i n g d a t a f r o m s l a v e r c e n c l e a r e d a u t o m a t i c a l l y w r i t e a c k e n = 1 s t a r t a c k n o w l e d g e s e q u e n c e , s d a = a c k d t = 1 a c k _ i s n o t s e n t w r i t e p e n = 1 h e r e m a s t e r t e r m i n a l t r a n s f e r s e t m s p i r q a t t h e e n d o f r e c e i v e s e t m s p i r q a t t h e e n d o f a c k n o w l e d g e s e q u e n c e d a t a s h i f t e d i n f a i l i n g e d g e o f s c l s e t m s p i r q a t t h e e n d o f r e c e i v e s e t m s p i r q a t t h e e n d o f a c k n o w l e d g e s e q u e n c e p b i t a n d m s p i r q b i t i s s e t l a s t b i t i s s h i f t e d i n t o m s p s r , m s p b u f i s n o t r e a d . m s p b u f i s s t i l l f u l l , m s p o v s e t
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 158 vers ion 1. 4 1 1 1 3 3 3 in system program flash rom 13.1 overview the sn8f2 7e65 mcu integrated device feature in - sy stem programmable (isp) flash memory for convenient, upgradeable code storage. the flash memory may be programmed via the sonix 8 bit mcu programming interface or by application code. the sn8f2 7e65 provides security options at the disposal of the designer to prevent unauthorized access to information stored in flash memory. isp flash rom provided user an easy way to storage data into flash rom. the isp concept is memory mapping idea that is to move ram buffer to flash rom. choice rom/ram address and executi ng rom programming command C pecmd, after programming words which controlled by peramcnt, peraml/peramcnt data will be programmed into address peroml/peromh. ram (byte) flash rom (word) ram address bit7 ~ bit0 rom address bit15 ~ bit8 bit7 ~ bit0 x data0 y data1 data0 x+1 data1 y+1 data3 data2 x+2 data2 => y+2 x+3 data3 y+3 x+n datan y+m datan datan - 1 during flash program or erase operation , t he mcu is stalled , although peripherals (timers, wdt, i/o, pwm, etc.) remain active. when pecmd register is set to execute isp progr am and erase operations, the program counter stops, op - code cant be dumped from flash rom, instruction stops operating, and program execution is hold not to active. at this time h ardware depends on isp operation configuration to do flash rom erasing and f lash rom programming automatically. a fter isp operation is finished, hardware release s system clock to make program counter running, system returns to last operating mode, and the next instruction is executed . recommend to add two nop instructions after isp operations . ? isp flash rom erase time = 25 ms 1 - page, 128 - word. ? isp flash rom program time = 28u s 1 - word. isp flash rom program time = 56u s 2 - word. isp flash rom program time = 448u s 16 - word. isp flash rom program time = 896u s 32 - word. ? note: 1. w atch dog timer should be clear before the flash write (program) or erase operation , or watchdog timer would overflow and reset system during isp operating. 2. besides program execution, all functions keep operating during isp operating, e.g. timer, adc, sio, uart, msp... all interrupt events still active and latch interrupt flags automatically. if any interrupt request occurs during isp operating, the interrupt request will be process by program after isp finishing.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 159 vers ion 1. 4 13.2 isp flash rom erase operati on isp flash rom erase operation is to clear flash rom contents to blank status 1 . erasing rom length is 128 - word and has rom page limitation. isp flash rom erase rom map is as following: isp rom map rom address bit0~bit6 (hex) 000 0 0001 000 2 0010 0 011 0050 0051 0070 0071 007e 007f rom address bit7~bit15 (hex) 0000 this page includes reset vector and interrupt sector. we strongly recommend to reserve the area not to do isp erase. 0080 one isp erase page 0100 one isp erase page 0180 one i sp erase page 0200 one isp erase page 0280 one isp erase page one isp erase page 0f00 one isp erase page 0f80 one isp erase page 1000 one isp erase page 1080 one isp erase page 1100 one isp erase page 1180 one isp erase page one isp erase page 1600 one isp erase page 1680 one isp erase page 1700 one isp erase page 1780 this page includes rom reserved area. we strongly recommend to reserve the area not to do isp erase. isp flash rom erase density is 128 - word which limits era se page boundary. the first 128 - word of flash rom (0x0000~0x007f) includes reset vector and interrupt vectors related essential program operation, and the last page 128 - word of flash rom (0x1780~0x17ff) includes system reserved rom area, we strongly recomm end do not execute isp flash rom erase operation in the two pages. flash rom area 0x0080~0x177f includes 46 - page for isp flash rom erase operation . the first step to do isp flash rom erase is to address rom - page location. the address must be the head loca tion of a page area , e.g. 0x0080, 0x0100, 0x0180 0x1600, 0x 1 6 80 and 0x1700. peroml [7:0] and peromh [ 7:0] d e fine the target starting address [ 15 :0] of f lash rom . write the start address into peroml and perom h registers, set pecmd register to 0xc3 , and th e system start to execute isp flash rom erase operation. ? example : use isp flash rom erase to clear 0x0080~0x00ff contents of flash rom. ; set erased start address 0x0080 . mov a, #0x80 b0mov peroml, a ; move low byte address 0x80 to peroml. mov a, #0x00 b0mov peromh, a ;move high byte address 0x00 to peromh ; clear watchdog timer. mov a,#0x5a b0mov wdtr,a ; start to execute isp flash rom erase operation. mov a,#0x c3 ; start to page erase. b0mov pecmd, a nop ; nop d elay nop ; the end of isp flash rom erase operation. the two nop instructions make a short delay to let system stable after isp flash rom erase operation. ? note: don t execute isp flash rom erase operation for the first page and the las t page, or affect program operation.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 160 vers ion 1. 4 13.3 isp flash rom progra m operation isp flash rom program operation is to write data into flash rom by program. program rom doesnt limit written rom address and length, but limits 32 - word density of one page. the numb er of isp flash rom program operation can be 1 - word ~ 32 - word at one time, but these words must be in the same page. isp flash rom program rom map is as following: isp rom map rom address bit0~bit4 (hex) 000 0 0001 000 2 000f 0010 001e 001f rom addre ss bit5~bit15 (hex) 0000 this page includes reset vector and interrupt sector. we strongly recommend to reserve the area not to do isp erase. 0020 one isp program page 0040 one isp program page 0060 one isp program page 0080 one isp program page 00a0 one isp program page 00c0 one isp program page 00e0 one isp program page 0100 one isp program page 0120 one isp program page one isp program page 1000 one isp program page 1020 one isp program page one isp program page 1700 one i sp program page 1720 one isp program page one isp program page 17 8 0 this page includes rom reserved area. we strongly recommend to reserve the area not to do isp erase. isp flash rom program page density is 32 - word which limits program page bound ary. the first 32 - word of flash rom (0x0000~0x001f) includes reset vector and interrupt vectors related essential program operation, and the last page 32 - word of flash rom (0x17 8 0~0x17ff) includes system reserved rom area, we strongly recommend do not exec ute isp flash rom program operation in the two pages. flash rom area 0x0020~0x17 7 f includes 1 87 - page for isp flash rom program operation . isp flash rom program operation is a simple memory mapping operation. the first step is to plan a ram area to store programmed data and keeps the ram address for is ram addressing. the second step is to plan a rom area will be programmed from ram area in isp flash rom program operation. the ram addressing is through peram l[9:0] 10 - bit buffer to configure the start ram a ddress. the ram data storage sequence is down - up structure. the first ram data is the low byte data of the first word of flash rom. the second ram data is the high byte data of the first word of rom, and so on. isp programming length is 1 - word~32 - word. i sp flash rom programming length is controlled by per a mcnt[7:3] bits which is 5 - bit format. before isp rom programming execution, set the length by program. peroml [7:0] and peromh [7:0] define the target starting address [15:0] of flash rom. write the star t address into peroml and peromh registers, set pecmd register to 0x5a, and the system start to execute isp flash rom program operation. if the programming length is over isp flash rom program page boundary, the hardware immediately stops programming fla sh rom after finishing programming the last word of the rom page. so it is very important to plan right rom address and programming length.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 161 vers ion 1. 4 ? case 1: 32 - word isp program. ram buffer length is 64 - byte and ram address is x ~ x+63. per a mcnt[7:3] =11111b meet s a complete on e page 32 - word of flash rom. the page address of flash rom is y ~ y+31. the y is the start address and set to peroml, peromh registers. ram (byte) flash rom (word) ram address 64 - byte bit7 ~ bit0 rom address 32 - word bit15 ~ bit8 bit 7 ~ bit0 x data0 y data1 data0 the head of the page. the start address of isp. x+1 data1 y+1 data3 data2 x+2 data2 => y+2 x+3 data3 y+3 x+ 62 data 62 x+ 63 data 63 y+ 31 data 63 data 62 the end of the page. the e nd address of isp. ? case 2: 16 - word isp program: ram buffer length is 32 - byte. p er a mcnt [7:3] =01111b meets 16 - word of flash rom. t he page a ddress of flash rom is y ~ y+31 , but the start address isn t the head of the page. define the start address is y+10 and set to peroml, peromh registers. the programmed flash rom area is y+10~y+25 addresses. ram (byte) flash rom (word) ram address 32 - byte bit7 ~ bit0 rom address 32 - word bit15 ~ bit8 bit7 ~ bit0 x data0 y the head of the page. x+1 data1 y+1 x+2 data2 => x+3 data3 y+ 10 data1 data0 the start address of isp. y+ 11 data3 data2 x+ 30 data 30 x+ 31 data 31 y+ 25 data 31 data 30 the end address of isp. y+ 3 0 y+ 31 the end of the page. ? case 3: follow above case and change the rom start address to y+20. the programmed flash rom area is y+20~y +35 addresses. the rom range is out of the page boundary. after isp flash rom operation, the last 4 - word data can t be written into flash rom successfully. t he programming length is over isp flash rom program page boundary, the hardware immediately stops programming flash rom after finishing programming the last word (y+31) of the rom page. ram (byte) flash rom (word) ram address 32 - byte bit7 ~ bit0 rom address 32 - word bit15 ~ bit8 bit7 ~ bit0 x data0 y the head of the page. x+1 data1 y+1 x+2 data2 => x+3 data3 y+ 20 data1 data0 the start address of isp. y+ 21 data3 data2 x+ 30 data 30 x+ 31 data 31 y+ 3 0 data 21 d ata 20 y+ 31 data 23 data 22 the end of the page. the end address of isp.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 162 vers ion 1. 4 ? example : use isp flash rom program to program 32 - word data to flash rom as case 1. set ram buffer start address is 0x010. set flash rom programmed start address is 0x0020. ; load data into 64 - byte ram buffer. ; set ram start address of 64 - byte buffer. mov a, #0x10 b0mov peraml, a ; set peram l[ 7 :0] to 0x20. mov a, #0x00 b0mov peramcnt, a ; set peram l[ 9:8 ] to 00b. ; set isp program lengt h to 32 - word. mov a, #11111000b or peramcnt, a ; set peram cnt [ 7 : 3 ] to 11111b. ; set programmed start address of flash rom to 0x0020. . mov a, #0x20 b0mov peroml, a ; move low byte address 0x20 to peroml. mov a, #0x00 b0mov peromh, a ;move high byte address 0x00 to peromh ; clear watchdog timer. mov a,#0x5a b0mov wdtr,a ; start to execute isp flash rom program operation. mov a,#0x 5a ; start to program flash rom. b0mov pecmd, a nop ; nop delay nop ; t he end of isp flash rom program operation. the two nop instructions make a short delay to let system stable after isp flash rom program operation. ? note: don t execute isp flash rom program operation for the first page and the last page, or af fect program operation.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 163 vers ion 1. 4 13.4 i sp program/erase control register 0dbh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pecmd pecmd 7 pecmd 6 pecmd 5 pecmd 4 pecmd 3 pecmd 2 pecmd 1 pecmd 0 read/write w w w w w w w w after reset - - - - - - - - bit [7:0] pecmd [7:0]: isp operation control register. 0x5a: page program (32 words / page) . 0xc3: page erase (128 words / page) . others: reserved. ? note: before executing isp program and erase operations , clear pecmd register is necessary . after isp configuration, set isp operation code in mov a,i and b0mov m,a instructions to start isp operations. 13.5 isp rom address register isp rom address length is 16 - bit and separated into peroml and pero m h registers . before isp execution, set the head address of isp rom by program. 0dch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 perom l perom l 7 perom l 6 perom l 5 perom l 4 perom l 3 perom l 2 perom l 1 perom l 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7: 0 ] peroml[7:0]: the low byte buffer of isp rom a ddress . 0ddh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 perom h perom h 7 perom h 6 perom h 5 perom h 4 perom h 3 perom h 2 perom h 1 perom h 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] perom h [7:0]: the high by te buffer of isp rom a ddress . 13.6 isp ram address register isp r a m address length is 1 0 - bit and separated into per a ml register and per amcnt[1:0] bits. before isp execution, set the head address of isp ram by program. 0deh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 peram l peram l 7 peram l 6 peram l 5 peram l 4 peram l 3 peram l 2 peram l 1 peram l 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] per aml [ 7:0]: isp r a m a ddress [7:0] . 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 b it 0 peramcnt peramcnt 7 peramcnt 6 peramcnt 5 peramcnt 4 peramcnt 3 - peram l 9 peram l 8 read/write r/w r/w r/w r/w r/w - r/w r/w after reset 0 0 0 0 0 - 0 0 bit [ 1 :0] per a m cnt [ 1 :0]: isp r a m a ddress [9:8] .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 164 vers ion 1. 4 13.7 isp rom programming length register isp programmin g length is 1 - word ~ 32 - word. isp rom programming length is contr olled by per a mcnt[7:3] bits which is 5 - bit format . before isp rom programming executio n, set the length by program. 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 peramcnt peramcnt 7 peramcnt 6 peramcnt 5 peramcnt 4 peramcnt 3 - peram l 9 peram l 8 read/write r/w r/w r/w r/w r/w - r/w r/w after reset 0 0 0 0 0 - 0 0 bit [ 7 : 3 ] per a m cnt [ 7 : 3 ]: isp rom programming length control register . isp programming length = per a mcnt[7:3] + 1 per a mcn t[7:3]=0: isp programming length is 1 - word. per a mcnt[7:3]=1: isp programming length is 2 - word. per a mcnt[7:3]=30: isp programming length is 31 - word. per a mcnt[7:3]=31: isp programming length is 32 - word. ? note: defines the number of word s wanted to be programmed. the maximum peramcnt [7:3] is 01fh , which program 32 words (64 bytes ram) to the flash. the minimum peramcnt [7:3] is 00h, which program only 1 word to the flash.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 165 vers ion 1. 4 1 1 1 4 4 4 instruction table f ield mnemonic description c dc z cycle mov a,m a ? m - - ? 1 m mov m,a m ? a - - - 1 o b0mov a,m a ? m (b an k 0) - - ? 1 v b0mov m,a m (bank 0) ? a - - - 1 e mov a,i a ? i - - - 1 b0mov m,i m ? i, m only supports 0x80~0x87 registers (e.g. pflag,r,y,z ) - - - 1 xch a,m a ? ? m - - - 1 +n b0xch a,m a ? ? m (bank 0) - - - 1 +n movc r, a ? rom [y,z] - - - 2 adc a,m a ? a + m + c, if occur carry, then c=1, else c=0 ? ? ? 1 a adc m,a m ? a + m + c, if occur carry, then c=1, else c=0 ? ? ? 1 +n r add a,m a ? a + m, if occur carry , then c=1, else c=0 ? ? ? 1 i add m,a m ? a + m, if occur carry, then c=1, else c=0 ? ? ? 1 +n t b0add m,a m (bank 0) ? m (bank 0) + a, if occur carry, then c=1, else c=0 ? ? ? 1 +n h add a,i a ? a + i, if occur carry, then c=1, else c=0 ? ? ? 1 m sbc a,m a ? a - m - /c, if occur borrow, then c=0, else c=1 ? ? ? 1 e sbc m,a m ? a - m - /c, if occur borrow, then c=0, else c=1 ? ? ? 1 +n t sub a,m a ? a - m, if occur borrow, then c=0, else c=1 ? ? ? 1 i sub m,a m ? a - m, if occur borrow, then c=0, else c=1 ? ? ? 1 +n c sub a,i a ? a - i, if occur borrow, then c=0, else c=1 ? ? ? 1 daa to adjust accs data format from hex to dec. ? - - 1 mul a,m r, a ? a * m, the lb of product stored in acc and hb stored in r register. zf affected by acc . - - ? 2 and a,m a ? a and m - - ? 1 l and m,a m ? a and m - - ? 1 +n o and a,i a ? a and i - - ? 1 g or a,m a ? a or m - - ? 1 i or m,a m ? a or m - - ? 1 +n c or a,i a ? a or i - - ? 1 xor a,m a ? a xor m - - ? 1 xor m,a m ? a xor m - - ? 1 +n xor a,i a ? a xor i - - ? 1 com m a ? m (1 s complement). - - ? 1 comm m m ? m (1 s complement). - - ? 1 swap m a (b3~b0, b7~b4) ? m(b7~b4, b3~b0) - - - 1 p swapm m m(b3~b0, b7~b4) ? m(b7~b4, b3~b0) - - - 1 +n r rrc m a ? rrc m ? - - 1 o rrcm m m ? rrc m ? - - 1 +n c rlc m a ? rlc m ? - - 1 e rlcm m m ? rlc m ? - - 1 +n s clr m m ? 0 - - - 1 s bclr m.b m.b ? 0 - - - 1 +n bset m.b m.b ? 1 - - - 1 +n b0bclr m.b m(bank 0).b ? 0 - - - 1 +n b0bset m.b m(bank 0).b ? 1 - - - 1 +n cmprs a,i zf,c ? a - i, if a = i, then skip next instruction ? - ? 1 + s b cmprs a,m zf,c ? a C m, if a = m, then skip next instruction ? - ? 1 + s r incs m a ? m + 1, if a = 0, then skip next instruction - - - 1+ s a incms m m ? m + 1, if m = 0, then skip next instruction - - - 1 +n +s n inc m a ? m + 1. - - ? 1 c incm m m ? m + 1. - - ? 1+n h decs m a ? m - 1, if a = 0, then skip next instruction - - - 1+ s decms m m ? m - 1, if m = 0, then skip next instruction - - - 1 +n +s dec m a ? m C 1 . - - ? 1 decm m m ? m C 1 . - - ? 1+n bts0 m.b if m.b = 0, then skip next instruction - - - 1 + s bts1 m.b if m.b = 1, then skip next instruction - - - 1 + s b0bts0 m.b if m(bank 0).b = 0, then skip next instruction - - - 1 + s b0bts1 m.b if m(bank 0).b = 1, then skip next instruction - - - 1 + s ts0m m if m = 0, z = 1. else z = 0. - - ? 1 jmp d pc15/14 ? rompages1/0, pc13~pc0 ? d - - - 2 call d stack ? pc15~pc0, pc15/14 ? rompages1/0, pc13~pc0 ? d - - - 2 callhl stack ? pc15~pc0, pc15~pc8 ? h register, pc7~pc0 ? l register - - - 2
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 166 vers ion 1. 4 callyz stack ? pc15~pc0, pc15~pc8 ? y register, pc7~pc0 ? z register - - - 2 m ret pc ? stack - - - 2 i reti pc ? stack, and to enable global interrupt - - - 2 s retlw i pc ? stac k, and load i to acc. - - - 2 c nop no operation - - - 1 note: 1. m is system register or ram. if m is system registers then n = 0, otherwise n = 1. 2. if branch condition is true then s = 1, otherwise s = 0.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 167 vers ion 1. 4 1 1 1 5 5 5 electrical characteristic 15.1 absolute maximum rat ing supply voltage (vdd) sn8f27e6 0 series .. . - 0.3v ~ 6.0v supply voltage (vdd) sn8f27e6 0l series .. .. . - 0.3v ~ 3.6 v input in voltage (vin) .. . vss C 0.2v ~ vdd + 0.2v operating ambient temperature (topr) sn8 f 27 e65 , sn8 f 27 e64, sn8 f 27 e62 .. .. .. C 4 0 ? c ~ + 8 5 ? c sn8 f 27 e65l , sn8 f 27 e64l, sn8 f 27 e62l . C 4 0 ? c ~ + 8 5 ? c storage ambient temperature (tstor) C 4 0 ? c ~ + 125 ? c 15.2 e lectrical characteri stic ? sn8f27e60 series dc characteristic (all of voltages refer to vss, vdd = 5.0v, f osc = 16 mhz, ambient temperature is 25 ? c unless otherwise n ote.) parameter sym . description min. typ. max. unit operating voltage vdd - 40 ? ? 1.8 - 5.5 v - 40 ? ? 2.5 5.5 v ram data retention voltage vdr 1.5 - - v * vdd rise rate vpor vdd rise rate to ensure int ernal power - on reset 0.05 - - v/ms input low voltage vil all input ports , reset pin, xin/xout pins. vss - 0.3 * vdd v input high voltage vih all input ports , reset pin, xin/xout pins. 0.7 * vdd - vdd v output low voltage vo l iol1=15ma, iol2=23ma. vss vss +0.5 v output high voltage voh ioh1=10ma, ioh2=13ma. vdd - 0.5 vdd v i/o port input leakage current ilekg pull - up resistor disable, vin = vdd - - 2 ua i/o port pull - up resistor rup 1 vin = vss , vdd = 3v , xin/xout pins. 120 240 360 k ? vin = vss , vdd = 5v , xin/xout pins. 60 120 180 rup 2 vin = vss , vdd = 3v , p0/p1/p4/p5 pins. 100 200 300 vin = vss , vdd = 5v , p0/p1/p4/p5 pins. 50 100 150 i/o output source current ioh 1 vop = vdd C 0.5v , xin/xout pins. 5 10 - ma ioh2 vop = vdd C 0.5v , p0/p1/p 4/p5 pins. 5 13 - i/o output sink current iol 1 vop = v ss + 0.5v , xin/xout pins. 8 15 - iol2 vop = v ss + 0.5v , p0/p1/p4/p5 pins. 8 23 - * intn trigger pulse width tint0 int0 interrupt request pulse width 2/fcpu - - cycle supply current (disable adc) idd1 run mode (n o loading ) vdd= 3 v , fcpu = 16mhz - 6.8 - ma vdd= 5 v , fcpu = 16mhz - 7 - ma vdd= 3 v , fcpu = 4mhz - 2.1 - ma vdd= 5 v , fcpu = 4mhz - 2.2 - ma vdd= 3 v , fcpu = 1mhz - 0.85 - ma vdd= 5 v , fcpu = 1mhz - 0.87 - ma vdd= 3 v , fc pu = 32khz/4 - 120 - u a vdd= 5 v , fcpu = 32khz/4 - 140 - u a idd2 slow m ode ( internal low rc, stop high clock ) vdd= 3 v , ilrc=16khz - 110 - u a vdd= 5 v , ilrc= 16 khz - 130 - u a idd3 sleep mode vdd= 3v - 90 - u a vdd= 5v - 100 - u a idd4 green mode (n o loading , watchdog disable) vdd= 3 v , ihrc=16mhz - 450 - ua vdd= 5 v , ihrc=16mhz - 500 - ua vdd= 3 v , ext. 32khz x tal - 110 - ua vdd= 5 v , ext. 32khz x tal - 130 - ua vdd= 3 v , ilrc=16khz - 110 - ua vdd= 5 v , ilrc= 16 khz - 120 - ua internal high oscillator freq. fihrc internal hihg rc (ihrc) 25 ? vdd= 2.4v~ 5. 5v 15.68 16 16.32 mhz - 40 ? ? vdd= 2.4v~ 5. 5v 15.4 16 16.5 mhz lvd voltage vdet0 low voltage reset level. 25 ? 1.7 1.8 1.9 v low voltage reset level. - 40 ? ? 1.6 1 .8 2.0 v vdet1 low voltage reset /indicator level. 25 ? 2.3 2.4 2.5 v low voltage reset /indicator level. - 40 ? ? 2.2 2. 4 2.6 v vdet2 low voltage reset /indicator level. 25 ? 3.2 3. 3 3.4 v low voltage reset /indicator level. - 40 ? ? 3.1 3. 3 3.5 v * these parameters are for design reference, not tested.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 168 vers ion 1. 4 ? sn8f27e60l series dc characteristic (all of voltages refer to vss, vdd = 3.0 v, f osc = 16 mhz, ambient temperature is 25 ? c unless otherwise n ote.) parameter sym. description min. typ. max. unit operating voltage vdd - 40 ? ? 1.8 3.0 3.3 v - 40 ? ? 2.5 3.0 3.3 v ram data retention voltage vdr 1.5 - - v * vdd rise rate vpor vdd rise rate to ensure internal power - on reset 0.05 - - v/ms input low voltage vil all input ports , reset pin, xin/xout pins. vss - 0.3 * vdd v input high voltage vih all input ports , reset pin, xin/xout pins. 0.7 * vdd - vdd v output low voltage vol iol1=9ma, iol2=14ma. vss vss+0.5 v output high voltage v oh ioh1=7ma, ioh2=8ma. vdd - 0.5 vdd v i/o port input leakage current ilekg pull - up resistor disable, vin = vdd - - 2 ua i/o port pull - up resistor rup 1 vin = vss , xin/xout pins. 120 240 360 k ? rup 2 vin = vss , p0/p1/p4/p5 pins. 100 200 300 i/o outp ut source current ioh 1 vop = vdd C 0.5v , xin/xout pins. 3 7 - ma ioh2 vop = vdd C 0.5v , p0/p1/p4/p5 pins. 4 8 - i/o output sink current iol 1 vop = v ss + 0.5v , xin/xout pins. 4 9 - iol2 vop = v ss + 0.5v , p0/p1/p4/p5 pins. 7 14 - * intn trigger pulse width tint0 int0 interrupt request pulse width 2/fcpu - - cycle supply current (disable adc) idd1 run mode (n o loading ) vdd= 3 v , fcpu = 16mhz - 7 - ma vdd= 3 v , fcpu = 4mhz - 1.9 - ma vdd= 3 v , fcpu = 1mhz - 0.73 - ma vdd= 3 v , fcpu = 32khz/4 - 35 - u a idd2 slow m ode ( internal low rc, stop high clock ) vdd= 3 v , ilrc=16khz - 25 - u a idd3 sleep mode vdd= 3v - 1 3 u a idd4 green mode (n o loading , watchdog disable) vdd= 3 v , ihrc=16mhz - 400 - ua vdd= 3 v , ext. 32khz x tal - 20 - ua vdd= 3 v , ilrc=16khz - 5 - ua internal high oscillator freq. fihrc internal hihg rc (ihrc) 25 ? vdd= 2.4v~ 5. 5v 15.68 16 16.32 mhz - 40 ? ? vdd= 2.4v~ 5. 5v 15.4 16 16.5 mhz lvd voltage vdet0 low voltage reset level. 25 ? 1.7 1.8 1.9 v low voltage rese t level. - 40 ? ? 1.6 1.8 2.0 v vdet1 low voltage reset /indicator level. 25 ? 2.3 2.4 2.5 v low voltage reset /indicator level. - 40 ? ? 2.2 2. 4 2.6 v vdet2 low voltage reset /indicator level. 25 ? 3.2 3. 3 3.4 v low voltage reset /indicator leve l. - 40 ? ? 3.1 3. 3 3.5 v * these parameters are for design reference, not tested. ? adc characteristic (all of voltages refer to vss, vdd = 5.0v, f osc = 4 mhz, fcpu=1mhz, ambient temperature is 25 ? c unless otherwise n ote.) parameter sym. description min . typ. max. unit ain0 ~ ain 11 input voltage vani vdd = 5.0v 0 - avrefh v adc reference voltage vref 2 - - v *adc enable time tast ready to start convert after set adenb = 1 100 - - us *adc current consumption i adc vdd=5.0v - 0.6 - ma vdd=3.0v - 0 .4 - ma adc clock frequency f adclk vdd=5.0v - - 8m hz vdd=3.0v - - 5m hz adc conversion cycle time f adcyl vdd=2.4v~5.5v 64 - - 1/f adclk adc sampling rate (set fads=1 frequency) f adsmp vdd=5.0v - - 125 k/sec vdd=3.0v - - 80 k/sec differential nonl inearity dnl vdd=5.0v , avrefh=3.2v, f adsmp =7.8k - 1 - +1 lsb integral nonlinearity inl vdd=5.0v , avrefh=3.2v, f adsmp =7.8k - 1 - +1 lsb no missing code nmc vdd=5.0v , avrefh=3.2v, f adsmp =7.8k 9 - 10 bits adc offset voltage v adc offset non - trimmed - 10 0 +10 mv trimmed - 2 0 +2 mv * these parameters are for design reference, not tested.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 169 vers ion 1. 4 ? flash me m ory characteristic (all of voltages refer to vss, vdd = 5.0v, f osc = 4 mhz, fcpu=1mhz, ambient temperature is 25 ? c unless otherwise n ote.) parameter sym. des cription min. typ. max. unit supply voltage vdd1 read mode 1.8 vdd v erase/program 2.5 vdd v endurance time ten1 erase + program, - 10 ? ? 20k *100k - cycle ten2 erase + program, - 40 ? ? 20k *70k - cycle page erase current ier vdd1=2.5v - 2 .5 5 ma program current ipg vdd1=2.5v - 3.5 7 ma page erase time ter vdd = 2.5v, 1 - page (128 - word). - - 30 ms program time tpg1 vdd = 2.5v, isp setup time. - - 380 us tpg2 vdd = 2.5v, 1 - word program. - - 30 us * these parameters are for design re ference, not tested. 15.3 characteristic graph s the graphs in this section are for design guidance, not tested or guaranteed. in some graphs, the data presented are outside specified operating range. this is for information only and devices are guaranteed to o perate properly only within the specified range.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 170 vers ion 1. 4 1 1 1 6 6 6 development tool sonix provides an embedded ice emulator system to offer sn8f27e65 firmware development. the platform is a in - circuit debugger and controlled by sonix m2ide soft ware on microsoft windows platform. the platform includes smart development adapter, sn8f27e65 starter - kit and m2ide software to build a high - speed, low cost, powerful and multi - task development environment including emulator, debugger and programmer. to e xecute emulation is like run real chip because the emulator circuit integrated in sn8f27e65 to offer a real development environment. sn8f27e65 embedded ice emulator system: sn8f27e65 embedded ice emulator includes: ? smart development adapter. ? usb cable to provide communications between the smart development adapter and a pc . ? sn8f27e65 starter - kit . ? modular c able to connect the smart development adapter and sn8f27e65 starter - kit or target board . ? cd - rom with m 2 ide software (m2 ide v124 or greater). sn8f27e65 embedded ice emulator feature: ? target s operating voltage: 1.8v~5.5v. ? up to 6 hardware break points. ? system clock rate up to 16mhz (fcpu=16mips). ? oscillator supports internal high speed rc, internal low speed rc, external crystal/resonator and external rc. sn8f27e65 embedded ice emulator limitation: ? eida and eick pins are shared with gpio pins. in embedded ice mode, the shared gpi function can t work. we strongly recommend planning the two pins as simple function which ca n be verified without debugger platform. s n 8 f 2 7 e 6 5 s t a r t e r - k i t s o n i x i d e / c - s t u d i o u s b c a b l e t o p c s o n i x e m b e d d e d i c e s m a r t d e v e l o p m e n t a d a p t e r m o d u l a r c a b l e t o s t a r t e r - k i t o r t a r g e t b o a r d
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 171 vers ion 1. 4 16.1 smart development ad apter smart development adapter is a high speed emulator for sonix embedded ice type flash mcu. it debugs and programs sonix flash mcu and transfers mcu s system status, ram data and system r egister between m2ide and sonix flash mcu through usb interface. t h e other terminal connected to sn8f27e65 starter - kit or target board is a 4 - wire serial interface. i n addition to debugger functions, the smart starter - kit system also may be used as a progr ammer to load firmware from pc to mcu for engineering production, even mass production. smart development adapter com munication with sn8f27e65 flash mcu is through a 4 - wire bus. the pin definition of the modular c able is as following: the modul ar cable can be inserted into sn8f27e65 starter - kit plugged into the target board or inserted into a matching socket at the target device on the target board. if the target board of application is desig ned and ready, t he modul ar cable can be inserted into the target directly to replace sn8f27e65 starter - kit. design the 4 - wire interface connected with sn8f27e65 ic to build a real application environment. in the mode, set sn8f27e65 ic on the target is nece ssary, or the emulation would be error without mcu. eida and eick share with p1.0/p1.1 gpio. in emulation mode, eida and eick are embedded ice interface and not execute gpio functions. t he p1.0/p1.1 gpio status still display on m2ide window to simulate p1.0/p1.1 program execution. v d d e i c k e i d a v s s s n 8 f 2 7 e 6 5 s t a r t e r - k i t u s b c a b l e t o p c s o n i x e m b e d d e d i c e s m a r t d e v e l o p m e n t a d a p t e r m o d u l a r c a b l e a p p l i c a t i o n t a r g e t b o a r d i c s o c k e t i / o c o n n e c t o r s c o n n e c t t o i c s o c k e t o f t a r g e t u s b c a b l e t o p c s o n i x e m b e d d e d i c e s m a r t d e v e l o p m e n t a d a p t e r m o d u l a r c a b l e t o s t a r t e r - k i t o r t a r g e t b o a r d a p p l i c a t i o n t a r g e t b o a r d s n 8 f 2 7 e 6 5 r e a l c h i p e m b e d d e d i c e 4 - w i r e i n t e r f a c e
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 172 vers ion 1. 4 16.2 sn8f27e65 starter - kit sn8f27e65 starter - kit is an easy - development platform. it includes sn8f27e65 real chip and i/o connectors to input signal or drive extra device of user s application. it is a simple platform to develop application as target board not ready. the starter - kit can be replaced by target board, because sn8f27e65 integrates embedded ice in - circuit debugger circuitry. the schematic and outline of sn8f27e65 starter - kit is as following : ? j1: dc 7.5v power adapter. ? jp2: vdd power source is 5.0v or 3.3v or external power. ? jp1/jp3: external power source. ? sw1: target power switch. ? u3: sn8f27e65f real chip (sonix standard option). ? d2: power led. ? d3: mcu led. ? c1 6 ~c 27 : 12 - ch adc capacitors . ? sw2: external reset trigger source. ? jp 5 ~jp 11 : i/o connector. ? y1, c 14 , c 15 : external crystal/resonator oscillator components. ? r 4 , c1 1 : external rc type oscillator components. ? jp12: vdd test pad and avrefh connector. p1.0 p1.2 p1.4 p1.6 p1.1 p1.3 p1.5 p1.7 vdd_50 vss p1.1 p1.0 vdd vdd_ext vdd_ext vdd_ext vdd_ext vss vss vss vss p4.4 p4.2 p4.5 p4.7 p4.1 p4.6 p4.3 p4.0 vdd p0.6 p0.6 vss vdd p0.5 p0.4 vdd vdd3v vss vss vdd p5.2 p5.1 p5.3 p5.0 p0.4 p0.5 p0.6 vss vdd3v vdd avrefh p4.0 p4.1 p4.2 p4.3 p4.4 p4.5 p4.6 p4.7 p0.3 p0.2 p0.1 p0.0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 p5.3 p5.2 p5.1 p5.0 avrefh p0.0 p0.2 p0.4 p0.6 p0.1 p0.3 p0.5 vss p4.0 p4.2 p4.4 p4.6 p4.1 p4.3 p4.5 p4.7 p5.0 p5.2 p5.1 p5.3 p0.2 p1.2 p0.3 p1.3 p1.4 p1.6 p1.5 p1.7 vss vss vss vss vss vss vss p5.3 p5.2 vss p5.1 vss vss vdd avrefh vdd avrefh vdd_50 vdd_sw vdd_50 vdd_33 vdd_sw vdd_33 vdd_ext vss y1 16m c14 20p c15 20p d1 1n4004 r3 47k c16 0.1u sw2 reset c17 0.1u c3 22u/16v c18 0.1u c19 0.1u c20 0.1u c21 0.1u c22 0.1u c23 0.1u sw1 power 1 2 d3 mcu led c4 0.1u c24 0.1u c27 0.1u c26 0.1u c25 0.1u u1 7805ct 1 3 2 in out gnd r2 470 jp5 port0 1 2 3 4 5 6 7 8 u2 aic1117_33 3 1 2 vin gnd vout jp7 port4 1 2 3 4 5 6 7 8 jp4 debug 1 2 3 4 5 6 7 8 9 10 c5 22u/16v r4 r jp1 vdd_ext 1 2 3 4 jp3 vss 1 2 3 4 jp2 1 2 3 4 c1 100u/16v jp12 vdd/avrefh 1 2 3 4 jp6 port1 1 2 3 4 5 6 7 8 u3 sn8f27e65f 14 1 2 7 8 9 10 11 12 13 15 3 4 16 5 6 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 p5.2 p0.3 p0.2 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 p5.3 p5.1 p0.1 p0.0 p5.0 p1.7 p1.6 p4.7 p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 p4.0 avrefh avdd/vdd vdd3v vreg vss p0.6 p0.5 p0.4 c12 0.1u c7 10u c13 10u c6 0.1u j1 dc 7.5v 2 3 1 jp8 port5 1 2 3 4 jp11 pwm 1 2 3 4 c11 cap c2 0.1u c10 0.1u jp9 uart/msp 1 2 3 4 r1 470 d2 pwr led c8 0.1u c9 10u jp10 sio 1 2 3 4 vdd_33 vdd_50 vdd_ext vdd pwm0 pwm2 pwm1 sdo sck sdi scs urx sda utx scl vdd avrefh
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 173 vers ion 1. 4 16.3 emulator/debugger installation ? insta ll the m2ide software (v124 or greater). ? connect smart development adapter with pc plugging in usb cable. ? attach the modular cable between smart development adapter and sn8f27e65 starter - k it or target. ? connect the power supplier to sn8f27e65 starter - k it or target , and turn off the power. ? open m2ide software and load firmware program (a project or a .asm file). ? turn on the power s witch of sn8f27e65 starter - k it or t arget. ? embedded ice emulator platform is installed, and start to execute debugger. s o n i x i d e / c - s t u d i o u s b c a b l e t o p c s o n i x e m b e d d e d i c e s m a r t d e v e l o p m e n t a d a p t e r s n 8 f 2 7 e 6 5 s t a r t e r - k i t s o n i x e m b e d d e d i c e s m a r t d e v e l o p m e n t a d a p t e r m o d u l a r c a b l e t o s t a r t e r - k i t o r t a r g e t b o a r d s o n i x e m b e d d e d i c e s m a r t d e v e l o p m e n t a d a p t e r m o d u l a r c a b l e t o s t a r t e r - k i t o r t a r g e t b o a r d a p p l i c a t i o n t a r g e t b o a r d s n 8 f 2 7 e 6 5 r e a l c h i p e m b e d d e d i c e 4 - w i r e i n t e r f a c e
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 174 vers ion 1. 4 16.4 programmer installat ion ? setup emulator/debugger environment first. ? compile the firmware program and generate a .sn8 file. ? execute download (f8) function of m2id e. ? open a .sn8 file and press enter to download firmware to sn8f27e65 starter - k it or target. ? turn off the power of sn8f27e65 starter - k it or target . ? disconnect sn8f27e65 starter - k it or target from smart development adapter. ? turn on the power of sn8f27e65 starter - k it or target , and mcu works independently.
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 175 vers ion 1. 4 1 1 1 7 7 7 rom programming pin sn8f27e60 series mcus flash rom erase/program/verify support sda, mp - pro writer and mp - iii writer. ? sda: embedded ice interface. ? mp - pro writer: plug on sn8f27e60 mcu s directly. ? mp - iii writer: for l version, the bias circuit must be set on the writer transition board. 17.1 mp - iii writer transition bo ard socket pin assignment mp - iii writer transition board: bias circuit: jp3 (mapping to 48 - pin text tool) : writer jp1/jp2 : dip 1 1 48 dip48 dip 2 2 47 dip47 dip 3 3 46 dip46 dip 4 4 45 dip45 dip 5 5 44 dip44 dip 6 6 43 dip43 dip 7 7 42 dip42 dip 8 8 41 dip41 dip 9 9 40 dip40 dip10 10 39 dip39 dip11 11 38 d ip38 dip12 12 37 dip37 dip13 13 36 dip36 dip14 14 35 dip35 dip15 15 34 dip34 dip16 16 33 dip33 dip17 17 32 dip32 dip18 18 31 dip31 dip19 19 30 dip30 dip20 20 29 dip29 dip21 21 28 dip28 dip22 22 27 dip27 dip23 23 26 dip26 dip24 24 25 dip25 vd d 1 2 gnd clk 3 4 ce pgm 5 6 oe d1 7 8 d0 d3 9 10 d2 d5 11 12 d4 d7 13 14 d6 vdd 15 16 vpp hls 17 18 rst - 19 20 alsb/pdb jp1 for writer transition board jp2 for dice and >48 pin package p i n 1 p i n 4 8 p i n 2 4 p i n 2 5 4 8 4 0 2 8 1 8 1 4 48 40 28 18 14 v d d g n d b i a s v o l t a g e 7 5 1 5 0 c o n n e c t t o t h e v d d p i n o f m p - i i i t r a n s i t i o n b o a r d . c o n n e c t t o t h e g n d p i n o f m p - i i i t r a n s i t i o n b o a r d .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 176 vers ion 1. 4 17.2 mp - iii writer programming pin mapp ing: programming pin information of sn8f27e65 series chip name sn8f27e65p /u (dip /s - dip ) sn8f27e65lp /u (dip /s - dip ) writer connector ic and jp3 48 - pin text tool pin assignment jp1/jp2 pin number jp1/jp2 pin name ic pin n umber ic pin name jp3 pin number ic pin n umber ic pin name jp3 pin number 1 vdd 30 vdd 38 31 vdd 39 2 gnd 1 vss 9 1 vss 9 3 clk 23 p 4 . 5 31 23 p 4 . 5 31 4 ce - - - - - - 5 pgm 22 p 4.6 30 22 p 4.6 30 6 oe 21 p 4.7 29 21 p 4.7 29 7 d1 - - - - - - 8 d0 - - - - - - 9 d3 - - - - - - 10 d2 - - - - - - 11 d5 - - - - - - 12 d4 - - - - - - 13 d7 - - - - - - 14 d6 - - - - - - 15 vdd - - - - - - 16 vpp 17 hls - - - - - - 18 rst - - - - - - 19 - - - - - - - 20 alsb/pdb 20 p 5.0 28 20 p 5.0 28 - bias voltage - - - 32 vdd 40 programming pin information of sn8f27e65 series chip name sn8f27e65f(lqfp) sn8f27e65j(qfn) sn8f27e65lf(lqfp) sn8f27e65lj(qfn) writer connector ic and jp3 48 - pin text tool pin assignment jp1/jp2 pin number jp1/jp2 pin name ic pin n umber ic pin name jp3 pin number ic pin n umber ic pin name jp3 pin number 1 vdd 26 vdd 34 27 vdd 35 2 gnd 29 vss 37 29 vss 37 3 clk 19 p 4 . 5 27 19 p 4 . 5 27 4 ce - - - - - - 5 pgm 18 p 4.6 26 18 p 4.6 26 6 oe 17 p 4.7 25 17 p 4.7 25 7 d1 - - - - - - 8 d0 - - - - - - 9 d3 - - - - - - 10 d2 - - - - - - 11 d5 - - - - - - 12 d4 - - - - - - 13 d7 - - - - - - 14 d6 - - - - - - 15 vdd - - - - - - 16 vpp 17 hls - - - - - - 18 rst - - - - - - 19 - - - - - - - 20 alsb/pdb 16 p 5.0 24 16 p 5.0 24 - bias voltage - - - 2 8 vdd 3 6
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 177 vers ion 1. 4 programming pin in formation of sn8f27e65 series chip name SN8F27E64k/s/x(skdip/sop/ssop) SN8F27E64lk/s/x(skdip/sop/ssop) writer connector ic and jp3 48 - pin text tool pin assignment jp1/jp2 pin number jp1/jp2 pin name ic pin n umber ic pin name jp3 pin number ic pin n umber ic pin name jp3 pin number 1 vdd 27 vdd 37 27 vdd 37 2 gnd 1 vss 11 1 vss 11 3 clk 22 p 4 . 5 32 22 p 4 . 5 32 4 ce - - - - - - 5 pgm 21 p 4.6 31 21 p 4.6 31 6 oe 20 p 4.7 30 20 p 4.7 30 7 d1 - - - - - - 8 d0 - - - - - - 9 d3 - - - - - - 10 d2 - - - - - - 11 d5 - - - - - - 12 d4 - - - - - - 13 d7 - - - - - - 14 d6 - - - - - - 15 vdd - - - - - - 16 vpp 17 hls - - - - - - 18 rst - - - - - - 19 - - - - - - - 20 alsb/pdb 19 p 5.0 29 19 p 5.0 29 - bias voltage - - - 28 vdd 38 programming pin in formation of sn8f27e65 series chip name SN8F27E64j(qfn) SN8F27E64lj(qfn) writer connector ic and jp3 48 - pin text tool pin assignment jp1/jp2 pin number jp1/jp2 pin name ic pin n umber ic pin name jp3 pin number ic pin n umber ic pin name jp3 pin number 1 vdd 23 vdd 33 2 3 vdd 33 2 gnd 25 vss 35 25 vss 35 3 clk 18 p 4 . 5 28 18 p 4 . 5 28 4 ce - - - - - - 5 pgm 17 p 4.6 27 17 p 4.6 27 6 oe 16 p 4.7 26 16 p 4.7 26 7 d1 - - - - - - 8 d0 - - - - - - 9 d3 - - - - - - 10 d2 - - - - - - 11 d5 - - - - - - 12 d4 - - - - - - 13 d7 - - - - - - 14 d6 - - - - - - 15 vdd - - - - - - 16 vpp 17 hls - - - - - - 18 rst - - - - - - 19 - - - - - - - 20 alsb/pdb 15 p 5.0 25 15 p 5.0 25 - bias voltage - - - 24 vdd 34
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 178 vers ion 1. 4 programming pin information of sn8f27e65 ser ies chip name sn8f27e62p/s(pdip/sop) sn8f27e62lp/s(pdip/sop) writer connector ic and jp3 48 - pin text tool pin assignment jp1/jp2 pin number jp1/jp2 pin name ic pin n umber ic pin name jp3 pin number ic pin n umber ic pin name jp3 pin number 1 vdd 19 vdd 33 19 vdd 33 2 gnd 1 vss 15 1 vss 15 3 clk 16 p 4 . 5 30 16 p 4 . 5 30 4 ce - - - - - - 5 pgm 15 p 4.6 29 15 p 4.6 29 6 oe 14 p 4.7 28 14 p 4.7 28 7 d1 - - - - - - 8 d0 - - - - - - 9 d3 - - - - - - 10 d2 - - - - - - 11 d5 - - - - - - 12 d4 - - - - - - 13 d7 - - - - - - 14 d6 - - - - - - 15 vdd - - - - - - 16 vpp 17 hls - - - - - - 18 rst - - - - - - 19 - - - - - - - 20 alsb/pdb 13 p 5.0 27 13 p 5.0 27 - bias voltage - - - 20 vdd 34
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 179 vers ion 1. 4 1 1 1 8 8 8 marking definition 18.1 introduction there are many different ty pes in sonix 8 - bit mcu production line. this note listed the production definition of all 8 - bit mcu for order or obtain information. this definition is only for blank flash rom mcu. 18.2 marking indetificati on system t i t l e s o n i x 8 - b i t m c u p r o d u c t i o n r o m t y p e m a t e r i a l b = p b - f r e e p a c k a g e g = g r e e n p a c k a g e t e m p e r a t u r e r a n g e s h i p p i n g p a c k a g e w = w a f e r , h = d i c e p = p - d i p , k = s k d i p s = s o p , x = s s o p f = l q f p , j = q f n d e v i c e 2 7 e 6 5 , 2 7 e 6 5 l 2 7 e 6 4 , 2 7 e 6 4 l 2 7 e 6 2 , 2 7 e 6 2 l s n 8 x p a r t n o . x x x - = - 4 0 ~ 8 5 f = f l a s h
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 180 vers ion 1. 4 18.3 marking examp le ? wafer, dice: name rom type device package temperature material s8 f 2 7e65 w flash 27e 6 5 wafer - 40 ~85 - sn8 f 2 7e65 h flash 27e65 dice - 40 ~85 - ? green package: name rom type device package temperature material sn8 f 2 7e65 p g flash 27e 6 5 p - dip - 40 ~85 green package sn8 f 2 7e65fg flash 27e65 lqfp - 40 ~85 green package sn8 f 2 7e65jg flash 27e65 qfn - 40 ~ 85 green package sn8f27e65 ug flash 27e65 s - dip - 40 ~85 green package sn8 f 2 7e65l p g flash 27e65 p - dip - 40 ~85 green package sn8 f 2 7e65lfg flash 27e65 lqfp - 40 ~85 green package sn8 f 2 7e65ljg flash 27e65 qfn - 40 ~85 green package sn8f27e65 l ug flash 27 e65 s - dip - 40 ~85 green package sn8 f 2 7e64kg flash 27e65 sk - dip - 40 ~85 green package sn8 f 2 7e64sg flash 27e65 sop - 40 ~85 green package sn8 f 2 7e64xg flash 27e65 ssop - 40 ~85 green package sn8 f 2 7e64jg flash 27e65 qfn - 40 ~85 green package sn8 f 2 7e64l kg flash 27e65 sk - dip - 40 ~85 green package sn8 f 2 7e64lsg flash 27e65 sop - 40 ~85 green package sn8 f 2 7e64lxg flash 27e65 ssop - 40 ~85 green package sn8 f 2 7e64ljg flash 27e65 qfn - 40 ~85 green package sn8 f 2 7e62 p g flash 27e65 p - dip - 40 ~85 green packa ge sn8 f 2 7e62sg flash 27e65 sop - 40 ~85 green package sn8 f 2 7e62l p g flash 27e65 p - dip - 40 ~85 green package sn8 f 2 7e62lsg flash 27e65 sop - 40 ~85 green package ? pb - free package: name rom type device package temperature material sn8 f 2 7e65 p b flash 27e65 p - dip - 40 ~85 pb - free package sn8 f 2 7e65fb flash 27e65 lqfp - 40 ~85 pb - free package sn8 f 2 7e65jb flash 27e65 qfn - 40 ~85 pb - free package sn8f27e65u b flash 27e65 s - dip - 40 ~85 pb - free package sn8 f 2 7e65l p b flash 27e65 p - dip - 40 ~85 pb - free package s n8 f 2 7e65lfb flash 27e65 lqfp - 40 ~85 pb - free package sn8 f 2 7e65ljb flash 27e65 qfn - 40 ~85 pb - free package sn8f27e65 l u b flash 27e65 s - dip - 40 ~85 pb - free package sn8 f 2 7e64kb flash 27e65 sk - dip - 40 ~85 pb - free package sn8 f 2 7e64sb flash 27e65 sop - 40 ~85 pb - free package sn8 f 2 7e64xb flash 27e65 ssop - 40 ~85 pb - free package sn8 f 2 7e64jb flash 27e65 qfn - 40 ~85 pb - free package sn8 f 2 7e64lkb flash 27e65 sk - dip - 40 ~85 pb - free package sn8 f 2 7e64lsb flash 27e65 sop - 40 ~85 pb - free package sn8 f 2 7e64lxb flash 27e65 ssop - 40 ~85 pb - free package sn8 f 2 7e64ljb flash 27e65 qfn - 40 ~85 pb - free package sn8 f 2 7e62 p b flash 27e65 p - dip - 40 ~85 pb - free package sn8 f 2 7e62sb flash 27e65 sop - 40 ~85 pb - free package sn8 f 2 7e62l p b flash 27e65 p - dip - 40 ~85 pb - free package sn8 f 2 7e62lsb flash 27e65 sop - 40 ~85 pb - free package
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 181 vers ion 1. 4 18.4 datecode system x x x x x x x x x y e a r m o n t h 1 = j a n u a r y 2 = f e b r u a r y . . . . 9 = s e p t e m b e r a = o c t o b e r b = n o v e m b e r c = d e c e m b e r s o n i x i n t e r n a l u s e d a y 1 = 0 1 2 = 0 2 . . . . 9 = 0 9 a = 1 0 b = 1 1 . . . . 0 3 = 2 0 0 3 0 4 = 2 0 0 4 0 5 = 2 0 0 5 0 6 = 2 0 0 6 . . . .
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 182 vers ion 1. 4 1 1 1 9 9 9 package information 19.1 p - dip 32 pin symbols min nor max min nor max (inch) (mm) a - - 0.2 2 0 - - 5.588 a1 0.015 - - 0.381 - - a2 0.1 50 0.155 0. 160 3.81 3.937 4.064 d 1.645 1.650 1.660 41.783 41.91 42.164 e 0. 6 00 bsc 15.24 bsc e1 0.540 0. 545 0. 550 13.716 13.843 13.97 l 0.115 0.130 0.150 2.921 3.302 3.81 b 0. 630 0. 650 0. 670 16.002 16.51 17.018 ? 0 7 15 0 7 15
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 183 vers ion 1. 4 19.2 lqfp 32 pin symbols min nor max min nor max (inch) (mm) a - - 0.063 - - 1.6 a1 0.002 0.004 0.006 0.05 0.1 0.15 a2 0.053 0.055 0.057 1.35 1.4 1.45 c1 0.004 0.005 0.006 0.09 0.125 0.16 d 0.354 bsc 9 bsc d1 0.276 bsc 7 bsc bsc e 0.354 bsc 9 bsc e1 0.276 b sc 7 bsc e 0.031 bsc 0.8 bsc b 0.012 0.015 0.018 0.3 0.375 0.45 l 0.018 0.024 0.030 0.45 0.6 0.75 l1 0.039 ref 1 ref
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 184 vers ion 1. 4 19.3 qfn 5x5 32 pin symbols min nor max min nor max (inch) (mm) a 0.003 0.030 0.031 0.070 0.750 0.800 a1 0.000 0.001 0.0 02 0.000 0.020 0.050 a3 0.008 ref. 0.203 ref. b 0.007 0.010 0.012 0.180 0.250 0.300 d 0.20 bsc 5.00 bsc e 0.20 bsc 5.00 bsc e 0.02 bsc 0.50 bsc l 0.014 0.016 0.018 0.350 0.400 0.450 k 0.008 - - 0.20 - - pad size d2 (mm) e2 (mm) min nor max min nor max 114x114 mil 2.60 2.70 2.75 2.60 2.70 2.75 134x134 mil 3.10 3.20 3.25 3.10 3.20 3.25
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 185 vers ion 1. 4 19.4 s - dip 32 pin symbols min nor max min nor max (inch) (mm) a 0.165 0.173 0.181 4.20 4.40 4.60 a1 0.043 - - 1.10 - - a2 0.126 0.130 0.134 3.20 3.30 3.40 a3 0.058 0.060 0.062 1.47 1.52 1.57 b 0.017 - 0.021 0.44 - 0.53 b1 0.017 0.018 0.019 0.43 0.46 0.48 b1 0.039 bsc 1.00bsc c 0.010 - 0.012 0.25 - 0.31 c 1 0.009 0.010 0.010 0.24 0.25 0.26 d 1.094 1.102 1.110 27.8 28.00 28.20 e1 0.343 0.350 0.358 8.70 8.90 9.10 e 0.07 bsc 1.778bsc ea 0.4 bsc 10.16bsc eb 0.400 - 0.466 10.16 - 11.84 ec 0.000 - 0.033 0 - 0.84 l 0.118 - - 3.00 - -
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 186 vers ion 1. 4 19.5 sk - dip 28 pin symbols min nor max min nor max (inch) (m m) a - - 0.210 - - 5.334 a1 0.015 - - 0.381 - - a2 0.114 0.130 0.135 2.896 3.302 3.429 d 1.390 1.390 1.400 35.306 35.306 35.560 e 0.310 7.874 e1 0.283 0.288 0.293 7.188 7.315 7.442 l 0.115 0.130 0.150 2.921 3.302 3.810 b 0.330 0.350 0.370 8.382 8. 890 9.398 ? 0 7 15 0 7 15
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 187 vers ion 1. 4 19.6 sop 28 pin symbols min nor max min nor max (inch) (mm) a 0.093 0.099 0.104 2.362 2.502 2.642 a1 0.004 0.008 0.012 0.102 0.203 0.305 d 0.697 0.705 0.713 17.704 17.907 18.110 e 0.291 0.295 0.299 7.391 7.493 7 .595 h 0.394 0.407 0.419 10.008 10.325 10.643 l 0.016 0.033 0.050 0.406 0.838 1.270 ? 0 4 8 0 4 8
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 188 vers ion 1. 4 19.7 ssop 28 pin symbols min nor max min nor max (inch) (mm) a - - 0.08 - - 2.13 a1 0.00 - 0.01 0.05 - 0.25 a2 0.06 0.07 0.07 1.63 1.7 5 1.88 b 0.01 - 0.01 0.22 - 0.38 c 0.00 - 0.01 0.09 - 0.20 d 0.39 0.40 0.41 9.90 10.20 10.50 e 0.29 0.31 0.32 7.40 7.8 0 8 .20 e1 0.20 0.21 0.22 5. 00 5.3 0 5.6 0 [e] 0.02 59bsc 0.65 bsc l 0.02 0.04 0.04 0.63 0.90 1. 03 r 0.00 - - 0.09 - - ? 0 4 8 0 4 8
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 189 vers ion 1. 4 19.8 qfn 4x4 28 pin symbols min nor max min nor max (inch) (mm) a 0.003 0.030 0.031 0.07 0.75 0.80 a1 0.000 0.001 0.002 0.00 0.02 0.05 a3 0. 008 ref. 0.20 ref. b 0.006 0.008 0.010 0.15 0.20 0.25 d 0.16 bsc 4.0 0 bsc e 0.16 bsc 4.00 bsc e 0.016 bsc 0.40 bsc l 0.014 0.016 0.018 0.35 0.40 0.45 k 0.008 - - 0.20 - - pad size d2 (mm) e2 (mm) min nor max min nor max 11 5 x11 5 mil 2. 5 0 2 .6 0 2.65 2. 5 0 2. 6 0 2. 6 5
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 190 vers ion 1. 4 19.9 p - dip 20 pin symbols min nor max min nor max (inch) (mm) a - - 0.210 - - 5.334 a1 0.015 - - 0.381 - - a2 0.125 0.130 0.135 3.175 3.302 3.429 d 0. 980 1.030 1.060 2 4 . 89 2 2 6 . 162 2 6 . 924 e 0.300 7.620 e1 0.245 0.250 0.255 6.223 6.350 6.477 l 0.115 0.130 0.150 2.921 3.302 3.810 b 0.335 0.355 0.375 8.509 9.017 9.525 ? 0 7 15 0 7 15
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 191 vers ion 1. 4 19.10 sop 20 pin symbols min nor max min nor max (inch) (mm) a 0.093 0.099 0.104 2.362 2.502 2.642 a1 0.004 0.008 0.012 0.102 0.203 0.305 d 0.496 0. 502 0.508 12.598 12.751 12.903 e 0 .291 0.295 0.299 7.391 7.493 7.595 h 0.394 0.407 0.419 10.008 10.325 10.643 l 0.016 0.033 0.050 0.406 0.838 1.270 ? 0 4 8 0 4 8
sn8 f27e60 series 8 - b it flash m icro - c ontroller with embedded ice and isp sonix technology co., ltd page 192 vers ion 1. 4 sonix reserves the right to make change without further notice to any products herein to im prove reliability, function or design . sonix does not assume any liability arising out of the application or use of any product or circuit described herein; neither does it convey any license under its patent rights nor the rights of others. sonix products are not designed, intended, or authorized for us as components in systems intended, for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the sonix product could create a situation where personal injury or death may occur. should buyer purchase or use sonix products for any such unintended or unauthorized application. buyer shall indemnify and hold sonix and its officers , employees, subsidiaries, affiliates and d istributors harmless against all claims, cost, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part. main office: address: 10f - 1, no.36, taiyuan street, chupei city, hsinchu, taiwan r.o.c. tel: 886 - 3 - 560 0888 fax: 886 - 3 - 560 0889 taipei office: address: 15f - 2, no.171, song ted road, taipei, taiwan r.o.c. tel: 886 - 2 - 2759 1980 fax: 886 - 2 - 2759 8180 hong kong office: unit 1519 , chevalier commercial centre, no.8 wang hoi road , kowloon bay, hong kong. t el : 852 - 2723 - 8086 f ax : 852 - 2723 - 9179 technical support by email : sn8fae@soni x.com.tw


▲Up To Search▲   

 
Price & Availability of SN8F27E64

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X